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.
This commit is contained in:
Paul Lietar
2013-11-30 02:45:32 +00:00
parent 56de22a3c8
commit 4e737e739f

View File

@@ -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