diff --git a/distillery/backup_all.sh b/distillery/backup_all.sh index 2da2148..c3ed912 100644 --- a/distillery/backup_all.sh +++ b/distillery/backup_all.sh @@ -26,27 +26,36 @@ log_info " => Making '$BACKUP_INSTANCE_DIR'" mkdir -p "$BACKUP_INSTANCE_DIR" mkdir -p "$DEPLOY_BACKUP_FINAL_DIR" -# backup the configuration -cp "$CONFIG_FILE" "$BACKUP_INSTANCE_DIR/.env" +function backup_everything() { + # backup the configuration + log_info " => Backing up configuration" + cp "$CONFIG_FILE" "$BACKUP_INSTANCE_DIR/.env" || true -# Backup the sql backup -log_info " => Backing up the SQL database" -dockerized_mysqldump --all-databases > "$BACKUP_SQL_FILE" + # Backup sql (complete) + log_info " => Backing up the SQL database" + dockerized_mysqldump --all-databases > "$BACKUP_SQL_FILE" || true -# Backup the triplestore system -log_info " => Backing up Triplestore System" -mkdir -p "$BACKUP_TRIPLESTORE_DIR" -curl -X GET -H "Accept:application/n-quads" $GRAPHDB_AUTH_FLAGS "http://127.0.0.1:7200/repositories/SYSTEM/statements?infer=false" > "$BACKUP_TRIPLESTORE_SYSTEM" + # Backup triplestore (complete) + log_info " => Backing up Triplestore System" + mkdir -p "$BACKUP_TRIPLESTORE_DIR" + curl -X GET -H "Accept:application/n-quads" $GRAPHDB_AUTH_FLAGS "http://127.0.0.1:7200/repositories/SYSTEM/statements?infer=false" > "$BACKUP_TRIPLESTORE_SYSTEM" || true -# backup individual repos -for REPO in `grep -oP '(?<=#repositoryID> ")[^"]+' $BACKUP_TRIPLESTORE_SYSTEM`; do - log_info " => Backing up Triplestore Repository '$REPO'" - curl -X GET -H "Accept:application/n-quads" $GRAPHDB_AUTH_FLAGS "http://127.0.0.1:7200/repositories/$REPO/statements?infer=false" > "$BACKUP_TRIPLESTORE_DIR/repo_$REPO.nq" -done + # backup triplestore (individual) + for REPO in `grep -oP '(?<=#repositoryID> ")[^"]+' $BACKUP_TRIPLESTORE_SYSTEM`; do + log_info " => Backing up Triplestore Repository '$REPO'" + curl -X GET -H "Accept:application/n-quads" $GRAPHDB_AUTH_FLAGS "http://127.0.0.1:7200/repositories/$REPO/statements?infer=false" > "$BACKUP_TRIPLESTORE_DIR/repo_$REPO.nq" || true + done -# backup the filesystem -log_info " => Backing up instance filesystem" -cp -rpT "$DEPLOY_INSTANCES_DIR" "$BACKUP_FILESYSTEM_DIR" + # backup all the instances + log_info "=> Backing up instances" + for slug in $(sql_bookkeep_list); do + log_info "=> /bin/bash '$DIR/backup_instance.sh' '$slug' '$BACKUP_INSTANCE_DIR/${slug}.tar.gz'" + /bin/bash "$DIR/backup_instance.sh" "$slug" "$BACKUP_INSTANCE_DIR/${slug}.tar.gz" 2>&1 | tee "$BACKUP_INSTANCE_DIR/${slug}.log" || true + done +} + +# do the entire backup +backup_everything 2>&1 | tee "$BACKUP_LOG_FILE.log" # Package the backup into a .tar.gz log_info " => Packaging '$BACKUP_FINAL_FILE'" diff --git a/distillery/backup_instance.sh b/distillery/backup_instance.sh index 17ed91c..aacbc60 100644 --- a/distillery/backup_instance.sh +++ b/distillery/backup_instance.sh @@ -80,7 +80,7 @@ function do_the_backup() { } # do the actual backup, writing it to a file -do_the_backup 2>&1 | tee "$BACKUP_LOG_FILE.log" +do_the_backup 2>&1 | tee "$BACKUP_LOG_FILE" # list before packaging log_info " => All backup files have been collected"