November 3, 20223 yr I'm writting a script to stop all runing containers and one VM, launch backup, start containers and VM and sync backup to onedrive. So I have most of it but is there a way to start only the dockers that were previosly started? basically I want to start only the containers with the autostart setting, I know I can type all the containers manually but I don't want to maintain the code and I would like something more automatic. The other question is what is the command to gracefully shutdown and start a VM? Edited November 3, 20223 yr by L0rdRaiden
November 6, 20223 yr Author In case is useful for someone this is how ended up my script for backup with Kopia and rclone sync #!/bin/bash #### DOCKERS AND VMs STOP #### /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Backup process started" -d "Start Kopia and stopping containers" -i "normal" docker start Kopia virsh shutdown AlmaLinux docker stop -t 120 HomeAssistant docker stop -t 120 MariaDBHA sleep 60s #### KOPIA BACKUP START #### /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Kopia backup started" -d "Kopia backup to drive" -i "normal" docker exec Kopia kopia snapshot create /app/data/Backup/UnraidOS docker exec Kopia kopia snapshot create /app/data/Docker docker exec Kopia kopia snapshot create /app/data/VMDisks/libvirt docker exec Kopia kopia snapshot create /app/data/VMDisks/AlmaLinux sleep 10s #### RCLONE SYNC START #### /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Rclone backup started" -d "Synchronizing backup to OneDrive" -i "normal" rclonelog="/mnt/user/Backup/Kopia/rclonelog.txt" rm $rclonelog rclone sync /mnt/user/Backup/Kopia onedrive:"/Backup/Kopia" --log-file=$rclonelog --log-level INFO #NOTICE Transfered1=$(grep "Transferred:" $rclonelog | grep "MiB" | tail -n 1) Checks=$(grep "Checks:" $rclonelog | tail -n 1) Deleted=$(grep "Deleted:" $rclonelog | tail -n 1) Transferred2=$(grep "Transferred:" $rclonelog | tail -n 1) Elapsedtime=$(grep "Elapsed time:"$rclonelog | tail -n 1) Warning=$(grep "warning:" $rclonelog | tail -n 1) Error=$(grep "error:" $rclonelog | tail -n 1) /usr/local/emhttp/webGui/scripts/notify -d "$Transfered1<br>$Checks<br>$Deleted<br>$Transferred2<br>$Elapsedtime<br>$Warning<br>$Error" #### DOCKERS AND VMs START #### virsh start AlmaLinux docker start MariaDBHA sleep 60s docker start HomeAssistant docker stop Kopia /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "Backup finished" -d "Synchronization completed" -i "normal" my next pending task is to find out how to get some output of the result of the backups in KOPIA to send a notification, similar to what I did with Rclone Edited November 6, 20223 yr by L0rdRaiden
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.