Jump to content

Community

Automatic backups


Steve Bullman
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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"

 

Link to comment
Share on other sites

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.

sample.png.123dc9a0757183ab332afa2745172ca7.png

Edited by jackflash
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy