update Repository sources
parent
2dbc359bd2
commit
302f9be36c
|
@ -0,0 +1,3 @@
|
|||
volumes
|
||||
apps/proxy
|
||||
.DS_Store
|
|
@ -1 +1 @@
|
|||
Subproject commit 1ef8c2a309d5905eae19d362d57c8dac9996f45f
|
||||
Subproject commit 0e3ecbb0a788f2afa5699185ef65901781d11c79
|
|
@ -1 +1 @@
|
|||
Subproject commit 1b500d84fac57f15099223ef63798f6778670040
|
||||
Subproject commit 2d8bcb6067b626ef0d83a364d070db3659bedcf3
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
# # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Konfiguration #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
# Verzeichnis, das gesichert werden soll
|
||||
source_dir="../volumes"
|
||||
# Verzeichnis, in dem die Backups gespeichert werden sollen
|
||||
backup_dir="/opt/docker_backups"
|
||||
# Anzahl der zu behaltenden Backups
|
||||
keep_backups=10
|
||||
# Aktuelles Datum und Uhrzeit
|
||||
current_datetime=$(date +"%Y-%m-%d_%H-%M-%S")
|
||||
# Name für das Backup-Archiv
|
||||
backup_filename="${current_datetime}-backup.tar"
|
||||
# Zielserver-Informationen
|
||||
remote_user="root"
|
||||
remote_server="TARGET NOT YET DEVICED"
|
||||
remote_dir="/opt/docker_backups"
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Ende der Konfiguration #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
remote_target="${remote_user}@${remote_server}"
|
||||
backup_fullpath="${backup_dir}/${backup_filename}"
|
||||
|
||||
# Docker-Container herunterfahren
|
||||
docker stop $(docker ps -q)
|
||||
# Erstelle das Backup-Archiv
|
||||
tar -cpf "${backup_fullpath}" "${source_dir}"
|
||||
# Docker-Container wieder starten
|
||||
docker start $(docker ps -a -q)
|
||||
# Komprimiere das Backup-Archiv
|
||||
gzip "${backup_fullpath}"
|
||||
backup_fullpath="${backup_fullpath}.gz"
|
||||
# Kopiere das Backup auf den Zielserver mit SCP ohne Passwort
|
||||
scp "${backup_fullpath}" "${remote_target}:$remote_dir/"
|
||||
# Lösche ältere lokale Backups mit `find`
|
||||
find "$backup_dir" -type f -name "*-backup.tar.gz" -mtime +$keep_backups -exec rm {} \;
|
||||
# Lösche ältere remote Backups mit `find`
|
||||
ssh "${remote_target}" "find ${remote_dir} -type f -name '*-backup.tar.gz' -mtime +$keep_backups -exec rm {} \;"
|
||||
|
||||
echo "Backup wurde erstellt: ${backup_fullpath} und auf ${remote_target} kopiert."
|
Loading…
Reference in New Issue