The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Looking for a script to Dump SQL and web files to server
Hi All
I've been trying to set-up a CRON on my PLESK server to dump the database and httpdocs once a day, keep 5 copies and delete anything older than 5 days old. Anyway I cant seem to get it to work and I was wondering what solutions everyone else use's to do the same thing? I was using a plugin back when I was running vBulletin v3 but would much rather do this via CRON on the server to bypass any issues if the domain is down and so on.. Xray |
#2
|
|||
|
|||
Log in to your server as root via SSH.
Create a file called backup.sh in your root directory. (this is where you should be when you log in as root via SSH. If you aren't there type cd /root) Put this code in the backup.sh file.. Code:
#!/bin/sh lastbackup=$(cat backup.txt) thisbackup=`expr $lastbackup + 1` if [ $thisbackup -eq 5 ] then echo 0 > backup.txt else echo $thisbackup > backup.txt fi GZIP="$(which gzip)" # Database username and password DBUSER=yourdatabaseusername DBPASS='yourdatabasepassword' # Name of the tar file to create FILE=master_backup_$thisbackup.tar.gz # Name of the database dump file to create DBFILE=db_backup.sql # Dump the contents of all databases to the database dump file mysqldump --opt -u $DBUSER -p$DBPASS --all-databases > $DBFILE # Create the tar file adding in the contents of 'httpdocs' # and the database dump file # Unless you want a huge list of files, redirect # output to /dev/null tar -zcvf $FILE $DBFILE /var/www/vhosts/yourwebsite.com/httpdocs > /dev/null # Remove the db sql file from the server. rm $DBFILE Create a cron task using crontab -e Put this in the task.. Code:
30 23 * * * /root/backup.sh > /dev/null 2>&1 master_backup_1.tar.gz master_backup_2.tar.gz master_backup_3.tar.gz master_backup_4.tar.gz master_backup_5.tar.gz As time progresses, the oldest file will be overwritten with a new backup. You need to check the file dates for the newest backup. In other words, after master_backup_5.tar.gz takes place, the count starts over and master_backup_1.tar.gz will be replaced by the new backup file. With all that said, it makes absolutely no sense to keep a backup of your site on the same server the site is on. If the server should fail, you won't have any backups at all. Backups should be transferred to some other location for safe keeping. |
Благодарность от: | ||
TheLastSuperman |
#3
|
||||
|
||||
Thank you so much for your help! I have been trying to get a backup solution up and running ever since I moved servers and upgraded from vB3 to vB4. I will see if I can set this up latter.
For an off site solution could you recommend anything? Lee |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|