update Repository sources
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -0,0 +1,3 @@
|
||||
volumes
|
||||
apps/proxy
|
||||
.DS_Store
|
Submodule apps/backend/src updated: 1ef8c2a309...0e3ecbb0a7
Submodule apps/frontend/src updated: 1b500d84fa...2d8bcb6067
44
scripts/backup.sh
Normal file
44
scripts/backup.sh
Normal file
@@ -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."
|
Reference in New Issue
Block a user