forked from stove/dataset
backup
This commit is contained in:
parent
7be018a275
commit
4d98ec14f1
3 changed files with 44 additions and 0 deletions
42
seed/base-machine/manual/install/backup
Executable file
42
seed/base-machine/manual/install/backup
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/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,6 +4,7 @@ RISOTTO_IMAGE_DIR="$RISOTTO_DIR/images"
|
|||
RISOTTO_SRV_DIR="$RISOTTO_DIR/srv"
|
||||
RISOTTO_CONFIG_DIR="$RISOTTO_DIR/configurations"
|
||||
MACHINES_DIR="/var/lib/machines"
|
||||
BACKUP_DIR="/root/backup"
|
||||
# image configuration
|
||||
IMAGE_BASE_RISOTTO_BASE_DIR="$RISOTTO_IMAGE_DIR/image_bases"
|
||||
IMAGE_NAME_RISOTTO_IMAGE_DIR="$RISOTTO_IMAGE_DIR/$IMAGE_NAME"
|
||||
|
|
|
@ -6,6 +6,7 @@ After=network.target local-fs.target systemd-logind.service
|
|||
Type=oneshot
|
||||
WorkingDirectory=%%host_install_dir
|
||||
ExecStart=%%host_install_dir/install_images %%host_name
|
||||
ExecStart=%%host_install_dir/backup %%host_name no
|
||||
ExecStart=%%host_install_dir/install_machines %%host_name
|
||||
|
||||
[Install]
|
||||
|
|
Loading…
Reference in a new issue