Syncronization Bash Script for Backup Purposes

Status
Not open for further replies.

Wyck

Wise, Aged Ars Veteran
148
I'm running a RH 7.2 server and have a primary archives drive and a backup archives drive. At this point I have a simple bash script that removes the entire contents of the backup drive, then copies the contents of the primary drive to it. I love the simplicity, but at this point it's nearing 100gb that is being copied, and that is very time consuming, resource consuming, and the inefficiency bugs me. I'd like a script that does some basic comparisons in order to cut the waste of time/resources significantly.

I'm here because I honestly don't know much about bash and was hoping for some guidence - plus, I'll bet there is a script out there somewhere that does this already.

The script would have two major functions:

Copying files. If it encounters a file that already exists, it needs to check for changes and replace it if there are in fact differences.

Removing files that had been deleted. If I had deleted a file on the primary drive, it would have to be deleted on the backup drive as well when the script is run. One possible way of doing this that occurs to me is to first complete the copy, then compare the drives and remove any files on the backup drive that don't exist on the primary.

Any guidance would be greatly appreciated. Fun stuff :)
 
Status
Not open for further replies.