Automated System Drive Backup Script

    • OMV 3.x
    • Resolved

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Automated System Drive Backup Script

      So now that I have have my system setup how I want it. I am now working on my backup plan, I am asking the community if they have any clue how to setup an automated clonezilla backup for the system drive. It should save at least 4 backups images, 1 per week to a USB Drive. It will also delete anything older than a month. Any assistance is greatly appreciated?. Thank you in advance. :)
    • takiyon wrote:

      automated clonezilla backup for the system drive
      It would be very, very difficult to automate a clonezilla backup because you would have to reboot into another customized Linux distro with clonezilla installed. Unless you really need the statistics or you change your OMV setup all the time, you shouldn't need to backup the system drive all the time. If you do, you might have to look into a manual install of REAR.
      omv 4.0.10 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!
    • ryecoaaron wrote:

      takiyon wrote:

      automated clonezilla backup for the system drive
      It would be very, very difficult to automate a clonezilla backup because you would have to reboot into another customized Linux distro with clonezilla installed. Unless you really need the statistics or you change your OMV setup all the time, you shouldn't need to backup the system drive all the time. If you do, you might have to look into a manual install of REAR.


      If not clonezilla what other methods are recommended? I know the plugin has a backup to a shared folder. Is it possible this can be automated instead? Also how can I restore if needed? Maybe clonezilla or clonezilla like answer is not the solution.

      Sent from my Pixel XL using Tapatalk
    • takiyon wrote:

      If not clonezilla what other methods are recommended?
      I suggested REAR in my previous post.

      takiyon wrote:

      I know the plugin has a backup to a shared folder. Is it possible this can be automated instead?
      Yes. Use the following command in a scheduled job in the web interface.

      takiyon wrote:

      lso how can I restore if needed?
      Backup a live system
      omv 4.0.10 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!
    • There is no need to backup the OS drive frequently unless there are a lot of changes being made.
      The more stuffs you install/changes, the more likely OMV may break.
      Clonezilla is one of the best cloning software.

      I use Clonezilla to back up OMV once a month.
      OMV v3.0
      Asus Z97-A/3.1; i3-4370
      32GB RAM Corsair Vengeance Pro
      4x3TB RAID10
    • tinh_x7 wrote:

      I use Clonezilla to back up OMV once a month.
      I use Proxmox and make a VM level backup on about the same frequency.
      omv 4.0.10 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!
    • I use scripts that run on cron to make a daily dd image of the system drive and purge those that are more than seven days old.

      How often the scripts run is determined by the cronjob settings, so it can be changed to whatever you want within the limits of what cron can do.

      How many backups are kept is also user configurable by setting the age of backups to keep.

      I'll post the scripts upon request, but you will have to customize them for your own drive labels, backup destination, and kept age.
      OMV 3.x - ASRock Rack C2550D4I - 16GB ECC - Silverstone DS380
    • gderf wrote:

      There are two scripts. One performs the backup. The other removes older backups.

      Both scripts must be edited for your particular situation.

      Both can be run on cron to automate the processes.
      Awesome! Thank you for the script.

      This I can work with. So just to clarify, once tweaked these scripts will make a direct copy of the live system drive to a backup drive. Am I correct? On the restore side what do I do? Do I just reverse the script and reboot the system? Will this process avoid clonezilla entirely? nothing against clonezilla and REAR but I am looking for a set and forget so I can start thinking about how to backup my data drives. Proxmox is cool too but I am running OMV on bare metal.
    • Yes, the backup script makes a bit for bit copy of a live running system drive to a single image file. Be advised that any changes to files that are made after they were written to the image will not be current when the image process is complete. So run the script when the system is not in use, and even then things like logs might not be consistent. That is the downside of backing up a live system.

      To restore take the drive containing the image file and a replacement system drive that is as large or larger than the original system drive to a machine (could be the same machine) and boot linux on it - a Live CD would work fine.

      Next identify the destination drive and the source drive with the image file and use dd to write the image file to the destination drive. Be careful and make sure you correctly identify the destination drive as it will be completely overwritten. dmesg or fdisk -l can be used to determine the device names for the drives and their sizes.

      For example:

      /dev/sda - drive with image file
      /dev/sdb - replacement system drive that will the target for the restore

      From a root shell:

      dd if=/dev/sda/full-path-to-image-file.img of= /dev/sdb

      When complete sync the disks and halt:

      sync
      shutdown -h now

      You should verify that the backups are being properly written. Cron sends me email, so maybe you can set yours the same way. You should also do a test restore to another drive and make sure it boots and runs properly. Don't wait for a system failure to occur and then find out the restore is not working.

      My OMV runs from a cheap 16GB SSD drive. I bought a few identical spares and tested this as above, so I know it works for me.

      There is no need for Clonezilla. But it may be possible to use it for the restore. I don't know, I never tried it.

      Good luck!
      OMV 3.x - ASRock Rack C2550D4I - 16GB ECC - Silverstone DS380
    • @gderf Do you run any databases on your system? I have cloned running systems with dd many times and usually don't have problems but I could see possibly having issues with a database like mysql.
      omv 4.0.10 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!
    • Change the dd line to this if you want a smaller file:

      dd if=/dev/disk/by-id/usb-SAMSUNG_SSD_UM410_Series_100000000000-0:0 bs=1M | gzip -c > $file

      You will just have to use something like this to restore it:

      gunzip -c $file | dd of=/dev/disk/by-id/usb-SAMSUNG_SSD_UM410_Series_100000000000-0:0 bs=1M

      edit - As gderf pointed out, gzip is slow. It may even cause the dd image to not work. I would probably compress it after creating the dd file.
      omv 4.0.10 arrakis | 64 bit | 4.13 backports kernel | omvextrasorg 4.1.0
      omv-extras.org plugins source code and issue tracker - github.com/OpenMediaVault-Plugin-Developers

      Please don't PM for support... Too many PMs!

      The post was edited 1 time, last by ryecoaaron ().