Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 08:12 pm EST

Geeklog Forums

Resetting database like the Geeklog Demo


Status: offline

rjrufo

Forum User
Regular Poster
Registered: 06/14/03
Posts: 95
I'd like to set up a demo site like the one used by the Geeklog Demo to show prospective clients. Is there a script that I can download that will reset the database? Or would I have to write my own?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
There's nothing special about that script. It's a cronjob that drops the database, creates a new one, imports the backup of the original state, and deletes a few files (uploaded userphotos, etc.). That's all.

bye, Dirk
 Quote

Status: offline

rjrufo

Forum User
Regular Poster
Registered: 06/14/03
Posts: 95
Ok, I guess that sounds simple enough, I'll work on it to see what I can do.

Thanks Dirk
 Quote

Status: offline

ScurvyDawg

Forum User
Full Member
Registered: 11/06/02
Posts: 523
A file example would be cool to see Dirk.

If your willing.
Mr. Green
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Text Formatted Code
#!/bin/sh

cd /path/to/geeklog/restore

/usr/local/bin/mysql -ugeeklog-user -ppasswd -e 'DROP DATABASE geeklog_demo;'
/usr/local/bin/mysql -ugeeklog-user -ppasswd -e 'CREATE DATABASE geeklog_demo;'
/usr/local/bin/mysql -ugeeklog-user -ppasswd -D geeklog_demo < backup.sql

cd ..

rm -f backups/*.sql

cd /path/to/geeklog/public_html

rm -f images/articles/*
rm -f images/userphotos/*

rm -f backend/*

touch backend/geeklog.rdf
chmod 666 backend/geeklog.rdf
 

As I said, nothing sophisticated in that script ...

Two important notes:
  1. Don't install the File Management plugin on a demo site - it could be used to upload, approve, and execute scripts

  2. Disable PHP in Static Pages in the plugin's config.php file. Otherwise, anyone could just enter and execute arbitrary PHP scripts

bye, Dirk
 Quote

julianna

Anonymous
Hi, Dirk.

I tried the script you provided, and I get the following output:

Text Formatted Code

/path/to/geeklog/restore/cronjob.txt: line 5: /usr/local/bin/mysql: is a directory
/path/to/geeklog/restore/cronjob.txt: line 6: /usr/local/bin/mysql: is a directory
/path/to/geeklog/restore/cronjob.txt: line 7: /usr/local/bin/mysql: is a directory


.
 


The database continues to be intact (I created an extra story which is not in the backup.sql file so I could see the difference).

Is there any reason why the cronjob would simply validate the existance of the directory rather than perform the task at hand? Is this something I need to address with my host?

This is my first time working with a cronjob.

Thanks.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
As the error message says: /usr/local/bin/mysql appears to be a directory instead of the mysql executable. While that's a bit odd, you'll have to find out where the executable resides (ask your hosting service if you can't figure it out).

bye, Dirk
 Quote

julianna

Anonymous
Oops. That's my mistake. When I read the script I thought I was supposed to point to the mysql directory. I'll ask them for the path to the mysql executable.

Thanks.
 Quote

julianna

Anonymous
It turns out my host doesn't allow access to the mysql executable for security reasons. Is there any other way I can automate the dropping, creating and populating of the database?

Thanks.
 Quote

julianna

Anonymous
After much more trial and error and some work with PHP, it turns out it was not working because of the "/usr/local/bin/". Once I got rid of that (I also didn't need the first two lines), everything worked perfectly!

Thanks.
 Quote

All times are EST. The time is now 08:12 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content