From 4e737e739f83d78f4602122d1b4593a4e8d2f99a Mon Sep 17 00:00:00 2001 From: Paul Lietar Date: Sat, 30 Nov 2013 02:45:32 +0000 Subject: [PATCH] Add a backup-check used to validate the archive. This allows plugins to refuse a backup, before the import process starts. Users can force the import using -f. --- plugins/backup/commands | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/backup/commands b/plugins/backup/commands index a4e406e79..9aa6cdc65 100755 --- a/plugins/backup/commands +++ b/plugins/backup/commands @@ -33,6 +33,13 @@ set -e; case "$1" in ;; backup:import) + if [[ $2 == "-f" ]]; then + force=true + shift + else + force=false + fi + INPUT_FILE="$2" [[ -z $INPUT_FILE ]] && INPUT_FILE="-" @@ -56,6 +63,15 @@ set -e; case "$1" in BACKUP_ROOT="$BACKUP_TMP_DIR""$DOKKU_ROOT" TARGET_DIR="$DOKKU_ROOT" + if ! pluginhook backup-check $VERSION "$BACKUP_ROOT" "$TARGET_DIR" "$BACKUP_TMP_DIR/.dokku_backup_apps"; then + if $force; then + echo "-f used. Ignoring warnings." + else + echo "Archive did not pass sanity checks. Use -f to import anyway" >&2 + exit 1 + fi + fi + # create all the app directories while read app; do mkdir "$TARGET_DIR/$app"; echo "Imported $app"; done < $BACKUP_TMP_DIR/.dokku_backup_apps