PDA

View Full Version : Database backup


ravensix
09-22-2015, 01:12 PM
Does anyone know how to do an automatic back up of the database for vB 5?

Dave
09-22-2015, 01:20 PM
This doesn't have to be done inside of vBulletin, you can simply setup a cronjob to execute a bash file to run mysqlbackup every X hours/days to make a backup to a certain location.

Then you could even execute a tool such as zip in the bash file to zip the backup and save some storage.

ravensix
09-22-2015, 02:43 PM
I have tried this but I dont have permission with this script. I can run just the mysqldump command manually and it works but as soon try to run the backup.sh script with the code below it says I dont have permission. Any ideas on how fix this? Thank you for your help.

#!/user/bin/sh
mysqldump -u root -p pwd --opt db1.sql > /respaldosql/db1.sql

Dave
09-22-2015, 03:13 PM
Try chmodding the file to allow execution: chmod u+x file.sh

ravensix
09-22-2015, 03:45 PM
I am now getting

-bash: ./backup.sh: /user/bin/sh^M: bad interpreter: No such file or directory
and with out /user
-bash: ./backup.sh: /bin/sh^M: bad interpreter: No such file or directory

--------------- Added 1442944340 at 1442944340 ---------------

Let me give you the actually code that I am using. Maybe this will help.

#!/bin/sh
mysqldump --no-create-db=true --opt -Q -h dbxxxxxxxx.db.1and1.com -u dbxxxxxxxxx -pxxxxxx dbxxxxxxxxxx > files/jaxreef.org`date +%m%d%y%H%M`.sql
find files/jaxreef* -mtime +5 -exec rm {} \;

Dave
09-22-2015, 04:59 PM
That happens when you create a new file on Windows, you have to open the backup.sh file in your editor and save it with "Unix" line endings.

Replicant
09-22-2015, 05:20 PM
This doesn't have to be done inside of vBulletin, you can simply setup a cronjob to execute a bash file to run mysqlbackup every X hours/days to make a backup to a certain location.

Then you could even execute a tool such as zip in the bash file to zip the backup and save some storage.

This is good advice. The best part is vb5 comes with a bash backup script (vb_backup.sh) in the do_not_upload folder. It automatically backs up the database, names it by dbname-date, and compresses it with gzip. You need to edit the path_to_config variable in the script.

ravensix
09-22-2015, 05:33 PM
Dave thank you for the help. It works now. :)

shimei
09-22-2015, 05:35 PM
Just in case anyone else is looking for how to do this.... I created a thread:

https://www.christforums.org/forum/entertainment-fun/computers-technology/2638-the-mysql-dump-code-for-cron