Jelajahi Sumber

[IMP] lookup databases

Gogs 6 tahun lalu
induk
melakukan
40db6eb267
2 mengubah file dengan 8 tambahan dan 7 penghapusan
  1. 7 6
      scripts/eiru-backup.sh
  2. 1 1
      scripts/eiru-bootup.sh

+ 7 - 6
scripts/eiru-backup.sh

@@ -2,6 +2,7 @@
 
 CONTAINER="database"
 DB_USER="odoo"
+ODOO_IMAGE="odoo/eiru:1.0"
 DATE=$(date +%Y%m%d)
 DAYS_TO_KEEP=15
 BKP_PATH="/mnt/backup/primary_local_bkp/pg"
@@ -22,7 +23,7 @@ perform_backups()
         mkdir "$BKP_TODAY_PATH"
     fi
 
-    for DB_NAME in $@; do
+    for DB_NAME in $(docker ps -a --format "{{.Names}}" --filter "ancestor=$ODOO_IMAGE"); do
         local TMP_FILE=$(printf "%s/%s.tar" "$TMP_PATH" "$DB_NAME")
 
         docker exec $CONTAINER pg_dump -U $DB_USER -d $DB_NAME -F tar -C -b -c -f $TMP_FILE
@@ -38,15 +39,15 @@ delete_old_backups()
 }
 
 # sync two backup paths
-sync_local_backups_path() 
+sync_backups_locally() 
 {
     rsync -arz $1 $2
 }
 
 # sync two backup paths remotely
-remote_sync_backups_path()
+sync_backups_remotely()
 {
-    rsync -arz "ssh -p $1" "$2@$3:$4" $5
+    rsync -arz "ssh -p $1" $2 "$3@$4:$5"
 }
 
 if [ ! -x "$(command -v docker)" ]; then
@@ -54,7 +55,7 @@ if [ ! -x "$(command -v docker)" ]; then
     exit 1
 fi
 
-perform_backups $@
+perform_backups
 delete_old_backups $BKP_PATH $DAYS_TO_KEEP
 
 if [ ! -x "$(command -v rsync)" ]; then
@@ -62,6 +63,6 @@ if [ ! -x "$(command -v rsync)" ]; then
     exit 1
 fi
 
-sync_local_backups_path "$BKP_PATH/" $SYNC_PATH
+sync_backups_locally "$BKP_PATH/" $SYNC_PATH
 
 exit 0

+ 1 - 1
scripts/eiru-bootup.sh

@@ -86,7 +86,7 @@ if [ ! -x "$(command -v docker)" ]; then
     exit 1
 fi
 
-if [ $1 == "stop"]; then
+if [ "$1" = "stop" ]; then
 	stop_monitor_systems
 	stop_odoo_systems golden athletic topjeans kava amojeans world clasi_calse tuspasos
 	stop_database_system