example conf for zfs-backup-mm script and copy_containers is now compatible for instalations, where is my backup-script used

This commit is contained in:
root 2020-05-17 11:05:28 +02:00
parent 5c82619b34
commit 46874ecef2
3 changed files with 40 additions and 2 deletions

View file

@ -3,6 +3,9 @@ __Features:__
copy_containers -> copy_containers ->
script for easy bulk container migrate via SSH between instalations of usl-mm script for easy bulk container migrate via SSH between instalations of usl-mm
zfs-backup-mm-example-config ->
Example config for zfs-backup-mm script, that backup all running containers, except those with "testing" or "deluge "in container name.
setup-usl-mm_install_requirements -> setup-usl-mm_install_requirements ->
install dialog utility install dialog utility

View file

@ -23,8 +23,8 @@ bionic_checker=$(ssh $DEST_IP -p $DEST_PORT lsb_release -c | awk {'print $2'})
for CONT in $CONTS; for CONT in $CONTS;
do do
CONT_VAR=$(echo "$CONTS_LIST"| sed -n "`echo "$CONT p" | sed 's/ //'`") CONT_VAR=$(echo "$CONTS_LIST"| sed -n "`echo "$CONT p" | sed 's/ //'`")
SNAPS_CLEANED=$(echo "$SNAPS" | grep crypt | grep lxd | grep storage | grep containers | grep -E "....-..-.._........--.d" | awk {'print $1'}) SNAPS_CLEANED=$(echo "$SNAPS" | grep crypt | grep lxd | grep storage | grep containers | grep -E "....-..-.._........--.d" | awk {'print $1'} | grep "$CONT_VAR"@)
DEST_SNAPS_CLEANED=$(echo "$DEST_SNAPS" | grep crypt | grep lxd | grep storage | grep containers | grep -E "....-..-.._........--.d" | awk {'print $1'}) DEST_SNAPS_CLEANED=$(echo "$DEST_SNAPS" | grep crypt | grep lxd | grep storage | grep containers | grep -E "....-..-.._........--.d" | awk {'print $1'} | grep "$CONT_VAR"@)
SOURCE_DEST_IDENTICAL_SNAPS=$(grep -Fxf <(echo "$SNAPS_CLEANED") <(echo "$DEST_SNAPS_CLEANED")) SOURCE_DEST_IDENTICAL_SNAPS=$(grep -Fxf <(echo "$SNAPS_CLEANED") <(echo "$DEST_SNAPS_CLEANED"))
SNAP_TO_SEND_FIRST=$(echo "$SOURCE_DEST_IDENTICAL_SNAPS" | tail -n1) SNAP_TO_SEND_FIRST=$(echo "$SOURCE_DEST_IDENTICAL_SNAPS" | tail -n1)
DATASET_VAR=$(echo "$DATASETS" | grep crypt | grep lxd | grep storage | grep containers | awk {'print $1'} | grep -E "$CONT_VAR"$) DATASET_VAR=$(echo "$DATASETS" | grep crypt | grep lxd | grep storage | grep containers | awk {'print $1'} | grep -E "$CONT_VAR"$)
@ -37,6 +37,9 @@ if [ -z "$SNAP_TO_SEND_FIRST" ]
then then
echo "Start move "$CONT_VAR"" echo "Start move "$CONT_VAR""
if [ -z "$SNAPS_CLEANED" ]
then
echo "Creating first snapshot" echo "Creating first snapshot"
for command in $(zfSnap -n -zpool28fix -a 7d "$DATASET_VAR" | grep snapshot | grep "$DATASET_VAR") for command in $(zfSnap -n -zpool28fix -a 7d "$DATASET_VAR" | grep snapshot | grep "$DATASET_VAR")
do do
@ -45,6 +48,10 @@ do
eval "$command"; eval "$command";
done done
else
SNAP_TO_SEND_FIRST=$(echo "$SNAPS_CLEANED" | tail -n 12 | head -n 1)
fi
echo "Sending first snapshot" echo "Sending first snapshot"
echo "Sending "$SNAP_TO_SEND_FIRST"" echo "Sending "$SNAP_TO_SEND_FIRST""
zfs send "$SNAP_TO_SEND_FIRST" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR" zfs send "$SNAP_TO_SEND_FIRST" | pv | ssh "$DEST_IP" -p $DEST_PORT zfs recv "$DEST_ZPOOL"/lxd/storage/containers/"$CONT_VAR"

View file

@ -0,0 +1,28 @@
#Backup server settings
backup_server="192.168.0.10"
backup_server_port="22"
backup_server_ipv=4
backup_server_dataset="tank/backups"
backup_server_delete_old_snaps=y
backup_server_number_keep_snaps=31
shape_megabytes=20
#Source server settings
#DO NOT CHANGE zfsnap_days_keep_snaps AFTER FIRST FULL BACKUP!
zfsnap_enable=y
zfsnap_days_keep_snaps=7
running_containers=$(lxc list | grep RUNNING | awk {'print $2'})
stopped_containers=$(lxc list | grep STOPPED | awk {'print $2'})
excluded_strings="deluge\|testing"
if [ -z "$stopped_containers" ]
then
source_datasets="$(zfs list | awk {'print $1'} | grep "crypt/lxd/storage/containers" | grep -ve "crypt/lxd/storage/containers$" | grep -e "$running_containers" | grep -ve "$excluded_strings")"
else
source_datasets="$(zfs list | awk {'print $1'} | grep "crypt/lxd/storage/containers" | grep -ve "crypt/lxd/storage/containers$" | grep -e "$running_containers" | grep -ve "$stopped_containers" | grep -ve "$excluded_strings")"
fi