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. :)

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • 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

    • Offizieller Beitrag

    If not clonezilla what other methods are recommended?

    I suggested REAR in my previous post.


    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.


    lso how can I restore if needed?

    Backup a live system

    omv 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    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 v5.0
    Asus Z97-A/3.1; i3-4370
    32GB RAM Corsair Vengeance Pro

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    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.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

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

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

    • Offizieller Beitrag

    @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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • No, I don't run any databases other than the rrd stuff for System Information | Performance Statistics graphs, and I don't care if those have holes in them or other oddities.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • So I modified and ran the script as and I wonder if there is a way to shrink the file size. Unfortunately my SSD is 60GB and the dd command will just make a 60GB image to my backup drive. After some googling I found the conv=sparse parameter which I tried and it did not help 58GB is what I got. Looks like its back to clonezilla again... :(

    • Offizieller Beitrag

    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 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    Einmal editiert, zuletzt von ryecoaaron ()

  • Sorry to open this old thread I am using the backup script for few months, working good, but since that, I just ran into the other one witch remove the oldest one

    My problem I ran the script without changing the default of 7days but even the one from today's date got purged in the dated directory?


    EDIT

    Sorry this is a normal behavior I watch it and it is working good.


Jetzt mitmachen!

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