wallas9512 Posted November 2, 2021 Share Posted November 2, 2021 I have a problem with certain docker Influxdb and Grafada won't be backup with this script. If I run backupDockers -b -d /mnt/user/NASBackup/dockers Grafada the script show : DATE: 2021-11-02-10-42-06-EDT DATE: 2021-11-02-10-42-06-EDT Thanks. Quote Link to comment
wgstarks Posted December 22, 2021 Share Posted December 22, 2021 @JoeUnraidUser I've been using your script successfully for several months but recently I just get line 2 permission denied when I try to run it. user script- #!/bin/bash /mnt/user/backups/backupDockers.sh -b unifi binhex-radarr binhex-sonarr binhex-qbittorrentvpn jackett mariadb tautulli PlexMediaServer plex-utills brunnhilde-diagnostics-20211221-2136.zip Quote Link to comment
wgstarks Posted December 22, 2021 Share Posted December 22, 2021 10 hours ago, wgstarks said: @JoeUnraidUser I've been using your script successfully for several months but recently I just get line 2 permission denied when I try to run it. user script- #!/bin/bash /mnt/user/backups/backupDockers.sh -b unifi binhex-radarr binhex-sonarr binhex-qbittorrentvpn jackett mariadb tautulli PlexMediaServer plex-utills 175.67 kB · 0 downloads Fixed On 11/2/2021 at 10:33 AM, wallas9512 said: Thank fot all. For make this script persistent (and futur scripts). Create folder with all script in /boot/config/scripts Add User Script run "at first array start only" > rsync -hrltgoD --chown=root:root --chmod=ugo=rwx /boot/config/scripts/ /usr/local/bin Thaks to all! Worked great. Couldn’t just call the script in User Scripts though. Had to use /usr/local/bin/backupDockers.sh. Quote Link to comment
FreddyGSanford Posted December 31, 2021 Share Posted December 31, 2021 For the life of me I cannot understand why this doesn't work for me. The file can no longer be downloaded, so on a Windows machine I opened Notepad++ copied the contents into a new file and saved as backupDockers.sh. I copied the file to X:\appdataBackup\containers\ this the path to the unRAID share where I have my weekly backups already going. I open terminal from the unRAID gui. I go to the path where I have the .sh file copied. I put this into the terminal window "backupDockers.sh -b -d /mnt/user/Backups/appdataBackup/containers/mariadb mariadb" This is the response I get back from the terminal window "bash: ./backupDockers.sh: /bin/bash^M: bad interpreter: No such file or directory" Quote Link to comment
bonienl Posted December 31, 2021 Share Posted December 31, 2021 You need to save the file in linux format not windows format. See the line ending setting in notepad++ Quote Link to comment
Squid Posted December 31, 2021 Share Posted December 31, 2021 (Or switch the line ending format with the config file editor plugin) Quote Link to comment
FreddyGSanford Posted December 31, 2021 Share Posted December 31, 2021 Yeah, I just figured that out since posting. I redid the file using VI inside the terminal. I figured saving as Unix format in NP++ would work. It did not. Thank you. Quote Link to comment
JoeUnraidUser Posted December 31, 2021 Share Posted December 31, 2021 1 hour ago, FreddyGSanford said: For the life of me I cannot understand why this doesn't work for me. The file can no longer be downloaded, so on a Windows machine I opened Notepad++ copied the contents into a new file and saved as backupDockers.sh. I copied the file to X:\appdataBackup\containers\ this the path to the unRAID share where I have my weekly backups already going. I open terminal from the unRAID gui. I go to the path where I have the .sh file copied. I put this into the terminal window "backupDockers.sh -b -d /mnt/user/Backups/appdataBackup/containers/mariadb mariadb" This is the response I get back from the terminal window "bash: ./backupDockers.sh: /bin/bash^M: bad interpreter: No such file or directory" I just tried downloading the file from the link and the download still works. Quote Link to comment
wgstarks Posted December 31, 2021 Share Posted December 31, 2021 Just now, JoeUnraidUser said: I just tried downloading the file from the link and the download still works. Yeah. Worked for me too. Quote Link to comment
Mustafa Aydin Posted December 4, 2022 Share Posted December 4, 2022 (edited) At first. The Script is working like a charm...I'm recognize it's backup only the Container that are sitting in appdata. The Cache folders are not in the backup list. And its also not possible to backup there with direkt command. There are also showed in the backuplist. ./backupDockers.sh -l Get only blank timestamps: DATE: 2022-12-04-12-23-15-CET DATE: 2022-12-04-12-23-15-CET What can we do here? Correct the cache-dir not solve the problem. cache="/mnt/cache" Thanks in advance. Edit: Its not backup all Docker Images that have some data in the cache directory. Edited December 4, 2022 by Mustafa Aydin Quote Link to comment
JoeUnraidUser Posted December 5, 2022 Share Posted December 5, 2022 On 12/4/2022 at 6:31 AM, Mustafa Aydin said: At first. The Script is working like a charm...I'm recognize it's backup only the Container that are sitting in appdata. The Cache folders are not in the backup list. And its also not possible to backup there with direkt command. There are also showed in the backuplist. ./backupDockers.sh -l Get only blank timestamps: DATE: 2022-12-04-12-23-15-CET DATE: 2022-12-04-12-23-15-CET What can we do here? Correct the cache-dir not solve the problem. cache="/mnt/cache" Thanks in advance. Edit: Its not backup all Docker Images that have some data in the cache directory. I'm not sure what you are trying to do. "./backupDockers.sh -l" only lists the dockers you have installed on the system, not the backups of the dockers. You should never use /mnt/cache as your backup directory. The backup will fail because it syncs the files to a folder called appdata in the backup directory. appdata is usually located in /mnt/cache/appdata. It would mean it is trying to overwrite itself. Quote Link to comment
tvd1 Posted March 10, 2023 Share Posted March 10, 2023 Not to bump an old thread, but is this still the best way to back up docker? I want to back up all dockers before doing any updates (and be able to restore). Lately most updates seem to break functionality and i'm sent on a several hour journey to figure out how to fix. I wish we could roll back updates, but this method will have to suffice if its still the best way. Quote Link to comment
trurl Posted March 10, 2023 Share Posted March 10, 2023 CA Backup / Restore Appdata plugin has been updated since this old thread and is probably what most use 1 Quote Link to comment
Peterca Posted September 19, 2023 Share Posted September 19, 2023 (edited) Hi guys, I use UserScripts to prepare/back up appdata (Dockers) and domains (VMs) and then i use Duplicacy to make backups. In Duplicacy i can then restore different versions from a dropdown. This way i can restore specific docker/VM back to Unraid. I'm an newbie at Unraid, rsync and tar so maybe this it totally wrong but it works for me. Please tell me if you have some idea's on how to improve (or maybe tell me to scrap it all 😄) DOCKERS #!/bin/bash # Get all running containers and store them in $CONTAINERS mapfile -t CONTAINERS < <( docker inspect --format='{{.Name}}' $(docker ps -q --no-trunc) | cut -c2- ) # show in logrun echo "Appdata backup started - Starting to shut down dockers" # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Notice [Script] -Appdata backup started" -i "normal" -d "Starting to shut down dockers" # Stop all running containers for container in "${CONTAINERS[@]}"; do echo "Stopping ${container}..." docker stop ${container} 1> /dev/null done # show in logrun echo "Dockers shutted down. Starting backup" # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Warning [Script] -Appdata backup running" -i "warning" -d "Dockers shutted down. Starting backup" # Backup appdata echo "Backing up /mnt/user/appdata/" rsync -a --delete /mnt/user/appdata/ /mnt/user/backups/appdatabackups/ # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Warning [Script] -Appdata backup running" -i "warning" -d "Backup done. Starting dockers" # Start all containers that were previously running for container in "${CONTAINERS[@]}"; do echo "Starting ${container}..." docker start ${container} 1> /dev/null done # show in logrun echo "Dockers started. Starting to tar files" # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Warning [Script] -Appdata backup running" -i "warning" -d "Dockers started. Starting to tar files" # Compress appdata and remove original folders find /mnt/user/backups/appdatabackups/ -type d -maxdepth 1 -mindepth 1 -exec tar zcvf {}.tar.gz {} --remove-files \; # show in logrun echo "Appdata backup done - Ready to do Duplicacy backup" # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Notice [Script] - Appdata backup done" -i "normal" -d "Ready to do Duplicacy backup" VMs #!/bin/bash #Empty vm list echo "" > /tmp/vms-running.txt # show in logrun echo "VMs backup started - Starting to shut down VMs" # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Notice [Script] -VMs backup started" -i "normal" -d "Starting to shut down VMs" #Get all running vms except VM-TO-NOT-SHUTDOWN server for VM in $(virsh list --state-running --name); do if [[ ! "$VM" == "VM-TO-NOT-SHUTDOWN" ]] ; then virsh shutdown "$VM" #Write running vms to list echo "$VM" >> /tmp/vms-running.txt fi done # sleep if no vm is started to get next notice sleep 5 # show in logrun echo "VMs shutted down. Starting backup" # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Warning [Script] -VMs backup running" -i "warning" -d "VMs shutted down. Starting backup" # Backup appdata echo "Backing up /mnt/user/domains/" rsync -a --delete /mnt/user/domains/ /mnt/user/backups/vmbackups/ # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Warning [Script] -VMs backup running" -i "warning" -d "Backup done. Starting VMs" #Get all running vms except backup server for VM in $(cat /tmp/vms-running.txt); do virsh start "$VM" done # show in logrun echo "VMs started. Starting to tar files" # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Warning [Script] -VMs backup running" -i "warning" -d "VMs started. Starting to tar files" # Compress appdata and remove original folders find /mnt/user/backups/vmbackups/ -type d -maxdepth 1 -mindepth 1 -exec tar zcvf {}.tar.gz {} --remove-files \; # show in logrun echo "VMs backup done - Ready to do Duplicacy backup" # Show notification in Unraid (alert, warning, normal) /usr/local/emhttp/webGui/scripts/notify -s "Notice [Script] - VMs backup done" -i "normal" -d "Ready to do Duplicacy backup" Edited September 19, 2023 by Peterca Quote Link to comment
OrdinaryButt Posted October 19, 2023 Share Posted October 19, 2023 On 3/10/2023 at 5:01 PM, trurl said: CA Backup / Restore Appdata plugin has been updated since this old thread and is probably what most use I might be wrong here and probably would like a dumb ass, but Appdata doesn't seem to be containing the ...how should I say this... the "installation files" (excuse me for the dirty Windows comparison, still learning Linux), with the Appdata being the config folder. I am guessing those are in the "docker image". Not really sure, I see some of my containers have many files and folders, some such as GluetunVPN only has 2 files in it's appdata folder. So, to match the topic's subject line, how can I go about backing up a docker container entirely, say before update of container, and if the updates breaks something (often for me with my luck), restore the previous version? I am thinking about switching my cache drive to ZFS and adding another ZFS pool, so I could take such backups perhaps. Quote Link to comment
strike Posted October 19, 2023 Share Posted October 19, 2023 41 minutes ago, OrdinaryButt said: So, to match the topic's subject line, how can I go about backing up a docker container entirely, say before update of container, and if the updates breaks something (often for me with my luck), restore the previous version? Backup of appdata is the only files you need. If you need to install the container again from scratch you can do that from the previous apps section in the apps tab. You can install all of your containers in like 2 min from there if you need to, in a single click. And you be up an running with the same settings as before provided you have backups of your appdata. As all your container template settings are saved on the flash drive. And with docker, roiling back to a previous version is so much easier then windows, or normal app install I should say (you can run docker on windows too) You just go to the docker template, switch to advanced view and put in the tag (version) you want in the repository filed. You can find all the tags for a container on dockerhub. No need to uninstall, just put in the tag hit apply and you're up in about 10 sec. Quote Link to comment
OrdinaryButt Posted October 20, 2023 Share Posted October 20, 2023 57 minutes ago, strike said: Backup of appdata is the only files you need. If you need to install the container again from scratch you can do that from the previous apps section in the apps tab. You can install all of your containers in like 2 min from there if you need to, in a single click. And you be up an running with the same settings as before provided you have backups of your appdata. As all your container template settings are saved on the flash drive. And with docker, roiling back to a previous version is so much easier then windows, or normal app install I should say (you can run docker on windows too) You just go to the docker template, switch to advanced view and put in the tag (version) you want in the repository filed. You can find all the tags for a container on dockerhub. No need to uninstall, just put in the tag hit apply and you're up in about 10 sec. What if older version is removed from repo? I have trust issues with "the cloud" Quote Link to comment
strike Posted October 20, 2023 Share Posted October 20, 2023 3 minutes ago, OrdinaryButt said: What if older version is removed from repo? I have trust issues with "the cloud" Not very likely, but it could happen, I guess. In that case you can use docker directory instead of the default docker image, then backup those too in addition to appdata. 1 Quote Link to comment
OrdinaryButt Posted October 20, 2023 Share Posted October 20, 2023 8 minutes ago, strike said: Not very likely, but it could happen, I guess. In that case you can use docker directory instead of the default docker image, then backup those too in addition to appdata. Thanks for the tips! Quote Link to comment
Recommended Posts
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.