开发者

Nightly backup and merging backup

I have a nightly back up script that makes a backup from one server of any files that have been modified and thensync them across to our back server.

/var/backups/backup-2011-04-02/backuped/ backuped files and folders

The format above is the nightly incremental backup, which copies all the files and folders to a date stamped folder and then another folder underneath.

Thinking of a script which would run after the back up script to merge all the files in the /var/backups/backup-2011-04-02/backuped/ into /var/www/live/documents

So in theory I need to merge a number of different folde开发者_如何学Crs from the backup into the live www on the backup server only with the right date

So whats the best way to go about this script?


You could run rsync on each backup directory to the destination in order of creation:

$ for f in `ls -t /var/backups`; do rsync -aL "/var/backups/$f" /var/www/live/documents/; done

Of course you can put this line in a nightly cron job. The only thing to look out for is the line above will choke if the filenames in your backup directory have spaces in them, but it looks like they don't, so you may be ok.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜