开发者

Automatically backing up a file to another server?

开发者 https://www.devze.com 2022-12-23 03:27 出处:网络
I have a backup created of my mysql database (vbulletin forum v3.8) eve开发者_StackOverflow中文版ryday. It\'s about 360mb in size. It\'s stored as one text file in a secure folder.

I have a backup created of my mysql database (vbulletin forum v3.8) eve开发者_StackOverflow中文版ryday. It's about 360mb in size. It's stored as one text file in a secure folder.

I'm thinking of getting another server, through a different host, and somehow automatically transferring the backup to my second server every day.

Any ideas on how I could automate this process? I'm thinking PHP and a cron job.


Cron definately. Php, if you like it, but using bash with mysqldump combined with gzip works wonders.


Schedule rsync to transfer the files (over ssh) with cron (if you're on Linux).


Cron + rsync may be your best bet. If the file is text as you say and the changes are "diff"able then rsync can be used to transfer only the updates to that file. For example, the crontab could look something like this:

20 4 * * * rsync -a --delete source/ username@remotemachine.com:/path/to/destination/

This will sync the remote machine once a day deleting any files in the remote copy that no longer exist on the source machine.

As a note, I just read again and noticed this is a mysql backup so they output of the dump could eventually contain binary and in that case you probably want to just use a replication server or copy the file whole each day. rsync could be used for the copy as well...


slightly different approach and technically not a backup solution, but might want to consider running mysql in a replication mode and replicating changes live. so if the worst happpens you will be up to date with the data and not a day behind.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号