My removable drive backup solution

  • 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:


    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


    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.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!