Everyone should have a backup strategy for their servers but some still don’t and if you are one of those people then you better act fast. I will suggest a few simple commands for a very basic but useful backup solution that might allow you to rest a little easier knowing that your data is [...]
Everyone should have a backup strategy for their servers but some still don’t and if you are one of those people then you better act fast. I will suggest a few simple commands for a very basic but useful backup solution that might allow you to rest a little easier knowing that your data is safe.
Mirroring the Data
We will use rsync for its ability to examine files and only transfer files that have been modified. The flags that are set tell rsync to:
Recurse into directories -r
Compress file data -z
rsync -rz user@remote_host /remote/path /local/path/of/copy
If you are simply trying to mirror your data to another server then that should do it for you. If you wish to take it one step further and retain multiple backups you should keep reading.
Data Retention
Since rsync only transfers files that have changed, what we will do is retain a copy of the server from the last rsync call so that we minimize both bandwidth and time. After every rsync call is complete we will archive and compress the current copy of the server.
cd /path/to/archives
tar -cf 'date +%F'.tar /local/path/of/copy
bzip2 'date +%F'.tar
That is all. It wasn’t that hard now was it?
Conclusion
After running these scripts, say, once a week, you will have a mirror of the server (dating back, in this case, at most a week) as well as as many prior backups your backup server can hold from previous weeks.
Comments are closed.
Content © Tom Milewski
Proudly powered by WordPress
Theme designed by Artisan Themes
19 queries.
0.387 seconds.