Steve Bullman Posted November 27, 2020 Posted November 27, 2020 Looking for a solution for automatic backups. Im moving my site across to a new VPS which only takes daily backups and only stores for one day. Would like to set something up where automatic backups can be made and preferably sent to a destination. Is this possible?
jackflash Posted November 27, 2020 Posted November 27, 2020 3 hours ago, Steve Bullman said: Looking for a solution for automatic backups. Im moving my site across to a new VPS which only takes daily backups and only stores for one day. Would like to set something up where automatic backups can be made and preferably sent to a destination. Is this possible? I am surprised that this is not possible in the admin panel. I was told that we use a cron job within the server itself. Our WP sites are backed up via the admin side though. Steve Bullman 1
Jock3r Posted November 27, 2020 Posted November 27, 2020 If it isn't a managed server then you can set it up with a cronjob. #!/bin/bash BACKUPTIME=`date +%b-%d-%y` DESTINATION=/root/backup/backup-$BACKUPTIME.tar.gz echo "Creating backup of database to $SQLDUMP" mysqldump --single-transaction --quick --databases forum | gzip -9 > $DESTINATION echo "Dump Zipped up" echo "Uploading zipped dump to the Amazon S3 bucket…" nice -n 10 ionice -c2 -n 7 s3cmd put $DESTINATION s3://cdn.myforumDB-backups/ echo "Removing the backup file $SQLDUMP" rm $DESTINATION echo "WooHoo! All done" And for files I have this #!/bin/bash BACKUPTIME=`date +%b-%d-%y` DESTINATION=/root/backups/backup-$BACKUPTIME.tar.gz SOURCEFOLDER=/srv/http/forum/root/html nice -n 10 ionice -c2 -n 7 tar -cpzf $DESTINATION $SOURCEFOLDER echo "Uploading zipped dump to the Amazon S3 bucket…" s3cmd put $DESTINATION s3://cdn.forum/Files-backups/ echo "Removing the backup file $SQLDUMP" rm $DESTINATION echo "WooHoo! All done" Steve Bullman and BomAle 2
jackflash Posted November 28, 2020 Posted November 28, 2020 (edited) For a cron job (shared or dedicated server) you can use this line: mysqldump -u DatabaseUser -p'DatabasePassword' DatebaseName > ExportFileName.sql Place this into the command space. You might have to edit this in text wrangler or equivalent. Edited November 28, 2020 by jackflash
Steve Bullman Posted November 29, 2020 Author Posted November 29, 2020 On 11/27/2020 at 7:47 PM, Jock3r said: If it isn't a managed server then you can set it up with a cronjob. #!/bin/bash BACKUPTIME=`date +%b-%d-%y` DESTINATION=/root/backup/backup-$BACKUPTIME.tar.gz echo "Creating backup of database to $SQLDUMP" mysqldump --single-transaction --quick --databases forum | gzip -9 > $DESTINATION echo "Dump Zipped up" echo "Uploading zipped dump to the Amazon S3 bucket…" nice -n 10 ionice -c2 -n 7 s3cmd put $DESTINATION s3://cdn.myforumDB-backups/ echo "Removing the backup file $SQLDUMP" rm $DESTINATION echo "WooHoo! All done" And for files I have this #!/bin/bash BACKUPTIME=`date +%b-%d-%y` DESTINATION=/root/backups/backup-$BACKUPTIME.tar.gz SOURCEFOLDER=/srv/http/forum/root/html nice -n 10 ionice -c2 -n 7 tar -cpzf $DESTINATION $SOURCEFOLDER echo "Uploading zipped dump to the Amazon S3 bucket…" s3cmd put $DESTINATION s3://cdn.forum/Files-backups/ echo "Removing the backup file $SQLDUMP" rm $DESTINATION echo "WooHoo! All done" Thanks for this. The second part for the files, is this images etc? If so do I need to back these up beings as i'm using AWS for these anyway?
Jock3r Posted November 29, 2020 Posted November 29, 2020 7 hours ago, Steve Bullman said: Thanks for this. The second part for the files, is this images etc? If so do I need to back these up beings as i'm using AWS for these anyway? It's pretty much the whole folder including apps and so on. I just do it to be safe.
bfarber Posted November 30, 2020 Posted November 30, 2020 This sort of thing typically needs to be done at the server level for anything beyond a very small site. PHP will time out very quickly attempting to back up most databases.
Steve Bullman Posted December 1, 2020 Author Posted December 1, 2020 23 hours ago, bfarber said: This sort of thing typically needs to be done at the server level for anything beyond a very small site. PHP will time out very quickly attempting to back up most databases. What method would you recommend please
bfarber Posted December 2, 2020 Posted December 2, 2020 It depends on a lot of factors. Many server administrator scripts such as WHM/cpanel, Plesk, etc. have the ability to take backups on a regular basis already and I'd just use one of those.
Recommended Posts