Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Docker and VM start / stop

Featured Replies

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 by L0rdRaiden

  • 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 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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.