27 lines
821 B
Bash
Executable file
27 lines
821 B
Bash
Executable file
#!/bin/bash -ex
|
|
|
|
BACKUP_DIR="/root/backup"
|
|
|
|
MACHINES=""
|
|
for nspawn in $(ls /etc/systemd/nspawn/*.nspawn); do
|
|
nspawn_file=$(basename $nspawn)
|
|
machine=${nspawn_file%.*}
|
|
if [ -d "/var/lib/risotto/srv/$machine" ]; then
|
|
MACHINES="$MACHINES$machine "
|
|
fi
|
|
done
|
|
|
|
cd /var/lib/risotto/srv/
|
|
mkdir -p "$BACKUP_DIR"
|
|
for machine in $MACHINES; do
|
|
BACKUP_FILE="$BACKUP_DIR/backup_$machine.tar.bz2"
|
|
rm -f "$BACKUP_FILE"
|
|
if [ -f "/var/lib/risotto/configurations/$machine/sbin/risotto_backup" ]; then
|
|
machinectl -q shell $machine /usr/local/lib/sbin/risotto_backup
|
|
tar --ignore-failed-read -cJf $BACKUP_FILE $machine/backup
|
|
elif [ ! -f "/var/lib/risotto/configurations/$machine/no_risotto_backup" ]; then
|
|
tar --ignore-failed-read -cJf $BACKUP_FILE $machine
|
|
fi
|
|
done
|
|
|
|
exit 0
|