From 9844ab07d3426653d4f2ffacd71645d2a0b83727 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sun, 22 May 2022 13:42:34 +0200 Subject: [PATCH] Scripts et configurations --- script_backups_aunt.sh | 6 ++ script_backups_mother.sh | 11 +++ virt-backup_aunt.yml | 128 +++++++++++++++++++++++++++ config.yml => virt-backup_mother.yml | 0 4 files changed, 145 insertions(+) create mode 100644 script_backups_aunt.sh create mode 100644 script_backups_mother.sh create mode 100644 virt-backup_aunt.yml rename config.yml => virt-backup_mother.yml (100%) diff --git a/script_backups_aunt.sh b/script_backups_aunt.sh new file mode 100644 index 0000000..c57158b --- /dev/null +++ b/script_backups_aunt.sh @@ -0,0 +1,6 @@ +#! /bin/bash + +echo "BACKUP SESSION $(date)" >> /var/log/backup.log +virt-backup backup 1>> /var/log/backup.log +virt-backup clean 1>> /var/log/backup.log + diff --git a/script_backups_mother.sh b/script_backups_mother.sh new file mode 100644 index 0000000..e4e608f --- /dev/null +++ b/script_backups_mother.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +rsync -avcHS --exclude 'var/backups' --exclude 'opt' --exclude 'sys' --exclude 'proc' --exclude 'dev' --delete / /var/backups/mother 1>> /var/log/backup.log +rsync -avcHS --exclude 'var/backups' --exclude 'opt' --exclude 'sys' --exclude 'proc' --exclude 'dev' --delete aunt.onlink:/ /var/backups/aunt 1>> /var/log/backup.log + +echo "BACKUP SESSION $(date)" >> /var/log/backup.log +virt-backup backup 1>> /var/log/backup.log +virt-backup clean 1>> /var/log/backup.log + +#find /var/backups -type f -exec sudo fallocate -v -d {} \; + diff --git a/virt-backup_aunt.yml b/virt-backup_aunt.yml new file mode 100644 index 0000000..9ce8026 --- /dev/null +++ b/virt-backup_aunt.yml @@ -0,0 +1,128 @@ +--- + +######################## +#### Global options #### +######################## + +## Be more verbose ## +debug: False + +## How many threads (simultaneos backups) to run. Use 0 to use all CPU threads +## detected, 1 to disable multitheading for backups, or the number of threads +## wanted. Default: 1 +threads: 0 + + +############################ +#### Libvirt connection #### +############################ + +## Libvirt URI ## +uri: "qemu+ssh://127.0.0.1:223/system" + +## Libvirt authentication, if needed ## +username: +passphrase: + + +####################### +#### Backup groups #### +####################### + +## Groups are here to share the same backup options between multiple domains. +## That way, it is possible, for example, to have a different policy retention +## for a pool of guests in testing than for the one in production. + +## Define default options for all groups. ## +default: + hourly: 0 + daily: 2 + weekly: 2 + monthly: 1 + yearly: 0 + +## Groups definition ## +groups: + ## Group name ## + aunt: + ## Backup directory ## + target: /var/backups/vm/aunt + + ## Packager to use for each backup: + ## directory: images will be copied as they are, in a directory per domain + ## tar: images will be packaged in a tar file + ## zstd: images will be compressed with zstd. Requires python "zstandard" package to be installed. + packager: directory + + ## Options for the choosen packager: + #tar: + ## # Compression algorithm to use. Default to None. + # compression: "xz" + #None | "xz" | "gz" | "bz2" + ## # Compression level to use for each backup. + ## # Generally this should be an integer between 1~9 (depends on the + ## # compression algorithm), where 1 will be the fastest while having + ## # the lowest compression ratio, and 9 gives the best compression ratio + ## # but takes the longest time to compress. + # compression_lvl: 5 + ## + ## zstd: + ## # Compression level to use for each backup. + ## # 1 will be the fastest while having the lowest compression ratio, + ## # and 22 gives the best compression ratio but takes the longest time + ## # to compress. + ## compression_lvl: [1-22] + #packager_opts: + # compression: xz + # compression_lvl: 6 + + ## When doing `virt-backup backup` without specifying any group, only + ## groups with the autostart option enabled will be backup. + autostart: True + + ## Retention policy: the first backup of the day is considered as the + ## "daily" backup, first of the week "weekly", etc. The following options + ## detail how many backups of each type has to be kept. Set to "*" or None for an + ## infinite retention. + ## Default to 5 for everything, meaning that calling "virt-backup clean" will let 5 + ## backups for each period not specified in the config. + hourly: 0 + daily: 2 + weekly: 2 + monthly: 1 + yearly: 0 + + ## Enable the Libvirt Quiesce option when taking the external snapshots. + ## + ## From Libvirt documentation: libvirt will try to freeze and unfreeze the guest + ## virtual machine’s mounted file system(s), using the guest agent. However, if the + ## guest virtual machine does not have a guest agent, snapshot creation will fail. + ## + ## However, virt-backup has a fallback mechanism if the snapshot happens to fail + ## with Quiesce enabled, and retries without it. + quiesce: False + + ## Hosts definition ## + hosts: + ## This policy will match the domain "domainname" in libvirt, and will + ## backup the disks "vba" and "vdb" only. + #- host: domainname + # disks: + # - vda + # - vdb + ## Quiesce option can also be overriden per host definition. + # quiesce: False + ## Will backup all disks of "domainname2" ## + #- domainname2 + ## Regex that will match for all domains starting with "prod". The regex + ## syntax is the same as the python one + - host: "r:.*" + # disks: + # - vda + + ## Exclude the domain domainname3 (useful with regex, for example) + #- "!domainname3" + ## Exclude all domains starting with "test" + - "!r:^generic.*" + +# vim: set ts=2 sw=2: diff --git a/config.yml b/virt-backup_mother.yml similarity index 100% rename from config.yml rename to virt-backup_mother.yml