I wanted to offer up my solution to create a rotating removable drive backup solution, maybe help someone else who wants to do something similar.
On my OMV server there are certain shared folders along with non shared folders that I wanted to keep backed up using a removable media. The usb-backup plugin was an option but I wanted something faster such as a removable hard drive.
Looked into the rsync jobs, but wanted something custom with notifications to swap drives after a period of time. So I have been using the method below:
- Installed a StarTech.com Black Aluminum 5.25in Rugged SATA Hard Drive Mobile Rack Drawer with an additional StarTech.com Extra Black Hard Drive Caddy for DRW150SATBK
- Had two spare 1TB hard drives from a previous setup to use as the backup drives
- Formatted the drives and used e2label and labeled the drives RemovableDrive_A and RemovableDrive_B respectively
- Created the following files on my server in folder /home/scripts/rmvbackup
- chkdriveage.sh
- extbackup.sh
- extbackup.txt
- rmvbackupjob.sh
- Added 2 scheduled jobs one for chkdriveage.sh (run at 2pm every day), rmvbackupjob.sh (run at 2:15am every day)
HERE is a .zip link of the scripts, I also attached it to the bottom of this post
There are 2 package dependencies used in the scripts, bc (for the floating point math) & mutt (my preferred email client, use it in other scripts of mine)
apt-get install bc
apt-get install mutt
Cliff notes version of the job process:
rmvbackupjob.sh is a wrapper for extbackup.sh to capture the output and send email log when complete
- extbackup.sh looks for a attached device with drive label RemovableDrive_* and mounts the drive
- Folders defined in the extbackup.sh script are synced the the mounted drive
- Time and use counter are updated in the extbackup.txt file
- Drive is unmounted and a joblog email is sent to the specified email in rmvbackjob.sh
Example email from script:
Backup start date/time .......: Wed 12/23/2015 at 02:15:01
Drive caddy loaded ...........: RemovableDrive_B
Data folders being backed-up .: Documents HomeMovies Music OMVBackups Photos SystemTools
OS folders being backed-up ...: /home/scripts
rsync summary statistics
----------------------------------------------------------------------
Number of files: 92961
Number of files transferred: 2
Total file size: 358.23G bytes
Total transferred file size: 68 bytes
Literal data: 68 bytes
Matched data: 0 bytes
File list size: 2.14M
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 2.15M
Total bytes received: 11.05K
sent 2.15M bytes received 11.05K bytes 333.03K bytes/sec
total size is 358.23G speedup is 165489.43
----------------------------------------------------------------------
Backup end date/time .........: Wed 12/23/2015 at 02:15:09
Alles anzeigen
chkdriveage.sh
- extbackup.txt file is read and the # of days specified in the script is compared to the first seen date
- Email is sent to the specified email in the script if the removable drive should be swapped
Example email from script:
** Required script changes **
chkdriveage.sh
- Change warndays to the # of days before change drive warning is emailed
- Change xxxx@gmail.com to your notification email
extbackup.sh
- Change sourcepath to your data drive path, mine is current value
- Change backupitems to each data drive folder to backup
- Change osbackupitems to each OS drive folder to backup
rmvbackupjob.sh
- Change xxxx@gmail.com to your notification email
This setup is custom for what I wanted to accomplish, this way I always have a rotating backup I store in a fire safe that at the most is a week old.