location: source_directories: - /var/backups/<%= @location_src %> repositories: - <%= @repo %> exclude_patterns: - '.zfs' one_file_system: false storage: compression: auto,zstd encryption_passphrase: <%= @repo_passphrase %> archive_name_format: "{hostname}-{now:%Y-%m-%d-%H%M%S}" ssh_command: ssh -i /root/.ssh/borgmatic retention: keep_daily: 7 keep_weekly: 4 keep_monthly: 12 keep_yearly: 1 prefix: "{hostname}-" consistency: checks: # Uncomment to always do integrity checks. # (takes long time for larger repos) #- repository - disabled check_last: 3 prefix: "{hostname}-" hooks: # Shell commands to execute before or after a backup before_backup: - echo "`date` - Starting custom actions" <% @before_backup.each do |action| %> - <%= action %> <% end %> - echo "`date` - Starting mysqldump" - for i in $(lxc list --format csv -c n); do lxc exec $i -- sh -c "test -x /usr/bin/mysqldump && /usr/bin/mysqldump --all-databases > /var/lib/mysql/dump.sql || true"; done - echo "`date` - Starting zfs-autobackup" - zfs-autobackup -v local <%= @location_src.split('/')[0] %> - echo "`date` - Starting borg" - for i in $(zfs get -r -t filesystem,volume autobackup:local <%= @location_src %> | grep 'autobackup:local.*true' | tail -n +2 | awk '{print $1}'); do zfs set mountpoint=/var/backups/${i} $i ; zfs mount -o ro $i; done after_backup: - for i in $(zfs get -r -t filesystem,volume autobackup:local <%= @location_src %> | grep 'autobackup:local.*true' | tail -n +2 | awk '{print $1}'); do zfs umount $i; done - echo "`date` - Finished backup" healthchecks: <%= @healthchecks %>