backup
This commit is contained in:
parent
e5f53eda0d
commit
21b6a1298d
2 changed files with 2 additions and 46 deletions
|
@ -1,42 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
HOST_NAME=$1
|
||||
START=$2
|
||||
if [ -z "$HOST_NAME" ]; then
|
||||
echo "usage: $0 host name"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. config.sh
|
||||
|
||||
MACHINES=""
|
||||
for image in *; do
|
||||
if [ -d "$image" ]; then
|
||||
for os in $image/configurations/*; do
|
||||
if [ -d "$os" ]; then
|
||||
machine="$(basename $os)"
|
||||
if [ -d "/var/lib/risotto/srv/$machine" ]; then
|
||||
MACHINES="$MACHINES$machine "
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
cd /var/lib/risotto/srv/
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
for machine in $MACHINES; do
|
||||
machinectl stop $machine || true
|
||||
while true; do
|
||||
machinectl status "$machine" > /dev/null 2>&1 || break
|
||||
sleep 1
|
||||
done
|
||||
BACKUP_FILE="$BACKUP_DIR/backup_$machine.tar.bz2"
|
||||
rm -f "$BACKUP_FILE"
|
||||
tar -cvJf $BACKUP_FILE $machine
|
||||
done
|
||||
|
||||
if [ -z "$START" ]; then
|
||||
machinectl start $MACHINES
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -4,10 +4,8 @@ After=network.target local-fs.target systemd-logind.service
|
|||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
WorkingDirectory=%%host_install_dir
|
||||
ExecStart=/usr/local/sbin/build_images
|
||||
ExecStart=%%host_install_dir/backup %%host_name no
|
||||
ExecStart=%%host_install_dir/install_machines %%host_name
|
||||
ExecStart=/usr/local/sbin/backup_images no
|
||||
ExecStart=/usr/local/sbin/update_images
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
Loading…
Reference in a new issue