ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    LXC Backup Script

    IT Discussion
    3
    6
    1.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Alex Sage
      last edited by Alex Sage

      #!/bin/bash
      echo
      echo "=============================="
      echo Stopping Containers.....
      echo "=============================="
      echo
      for i in $(ls /var/lib/lxc); do lxc-stop -n $i ; done
      echo Done!
      echo
      echo "=============================="
      echo Backing Up Containers.....
      echo "=============================="
      echo
      cd /var/lib/lxc/
      for i in $(ls /var/lib/lxc); do tar --numeric-owner -czf /root/backups/lxc/$i.tgz $i ; done
      echo Done!
      echo
      echo "=============================="
      echo Starting Containers.....
      echo "=============================="
      echo
      for i in $(ls /var/lib/lxc); do lxc-start -n $i ; done
      echo Done!
      echo
      echo "=============================="
      echo Syncing Container Backups to B2.....
      echo "=============================="
      echo
      b2 sync --keepDays 30 --replaceNewer /root/backups/lxc b2://aaronstuder/backups/lxc
      echo Done!
      echo
      echo "=====Backup Complete!====="
      
      1 Reply Last reply Reply Quote 4
      • A
        Alex Sage
        last edited by

        Any feedback is welcome 🙂

        1 Reply Last reply Reply Quote 0
        • D
          dafyre
          last edited by

          I like it. Nice and easy!

          What is B2? Backblaze?

          D 1 Reply Last reply Reply Quote 0
          • D
            DustinB3403 @dafyre
            last edited by

            @dafyre said in LXC Backup Script:

            I like it. Nice and easy!

            What is B2? Backblaze?

            Yes Back Blaze B2.

            1 Reply Last reply Reply Quote 0
            • A
              Alex Sage
              last edited by

              I can add support for AWS if anyone wants it. I added B2 because it's cheaper 🙂

              1 Reply Last reply Reply Quote 1
              • A
                Alex Sage
                last edited by

                I should add, with --keepDays 30 tells B2 to keep 30 days worth of versions.

                1 Reply Last reply Reply Quote 1
                • 1 / 1
                • First post
                  Last post