Welcome to Geeklog, Anonymous Friday, June 09 2023 @ 04:44 am EDT
Geeklog Forums
Resetting database like the Geeklog Demo
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
bye, Dirk
5
4
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.
If your willing.

3
4
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Text Formatted Code
#!/bin/shcd /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:
- Don't install the File Management plugin on a demo site - it could be used to upload, approve, and execute scripts
- Disable PHP in Static Pages in the plugin's config.php file. Otherwise, anyone could just enter and execute arbitrary PHP scripts
bye, Dirk
5
3
Quote
julianna
Anonymous
Hi, Dirk.
I tried the script you provided, and I get the following output:
/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.
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.
5
4
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
bye, Dirk
2
4
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.
Thanks.
4
4
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.
Thanks.
5
5
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.
Thanks.
3
3
Quote
All times are EDT. The time is now 04:44 am.
- 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