umask 0022 USER_ROOT=/home/fasoonli BACKUP_ROOT=$USER_ROOT/website-backups SCRIPT_BACKUP=backup-website SCRIPT_RESTORE=restore-website SCRIPT_LIST=list-backups SCRIPT_REMOVE=delete-backup DB_NAMES="fasoonli fasoonli_dev" METATXT="meta.txt" MYSQLDUMP=/usr/bin/mysqldump MYSQL=/usr/bin/mysql RSYNC=/usr/bin/rsync GZIP=/bin/gzip ZCAT=/bin/zcat #BASE64=$USER_ROOT/my-encode.py BASE64="/usr/bin/env python2 $USER_ROOT/my-encode.py" STAT=/usr/bin/stat quote_name() { local NAME_TO_QUOTE="$1" local QUOTED_NAME=$(echo -n "$NAME_TO_QUOTE" | $BASE64) echo -n "$QUOTED_NAME" } list_all_backups() { for d in $(ls -1 $BACKUP_ROOT); do local FULLMETA="$BACKUP_ROOT/$d/$METATXT" if [ -e "$FULLMETA" ]; then echo "$d" fi done } find_backup_by_name() { local BACKUP_NAME_TO_FIND="$1" local BACKUP_NAME_Q=$(quote_name "$BACKUP_NAME_TO_FIND") local BACKUP_PATH="$BACKUP_ROOT/$BACKUP_NAME_Q" if [ -d "$BACKUP_PATH" ]; then local FULLMETA="$BACKUP_PATH/$METATXT" if [ -e "$FULLMETA" ]; then local BACKUP_NAME_FOUND=$(cat "$FULLMETA") if [[ "$BACKUP_NAME_TO_FIND" == "$BACKUP_NAME_FOUND" ]]; then echo -n "$BACKUP_NAME_Q" exit fi fi fi echo -n "" }