Tidying of backup and restore

This commit is contained in:
Bob Mottram 2016-10-02 15:23:04 +01:00
parent c9435e5c8f
commit 20dffe1b61
2 changed files with 22 additions and 32 deletions

View File

@ -91,16 +91,12 @@ function create_mirrors_user {
return
fi
create_password='no'
if [ ! "$MY_MIRRORS_PASSWORD" ]; then
create_password='yes'
fi
if [ ${#MY_MIRRORS_PASSWORD} -lt ${MINIMUM_PASSWORD_LENGTH} ]; then
echo $'Password is too short. Creating new one.'
create_password='yes'
create_password=1
if [ ${#MY_MIRRORS_PASSWORD} -ge ${MINIMUM_PASSWORD_LENGTH} ]; then
create_password=
fi
if [[ $create_password == 'yes' ]]; then
if [ $create_password ]; then
MY_MIRRORS_PASSWORD="$(openssl rand -base64 20 | cut -c1-18)"
fi

View File

@ -365,43 +365,37 @@ function backup_database_to_friend {
function backup_apps {
localremote=$1
FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
BACKUP_APPS_COMPLETED=()
# for all the app scripts
for filename in $FILES
detect_installable_apps
get_apps_installed_names
for app_name in "${APPS_INSTALLED_NAMES[@]}"
do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
if [[ $(item_in_array ${app_name} ${BACKUP_APPS_COMPLETED[@]}) != 0 ]]; then
if [[ "$(app_is_installed $a)" == "1" ]]; then
BACKUP_APPS_COMPLETED+=("${app_name}")
backup_${localremote}_${app_name}
fi
fi
echo $"Backup ${app_name}"
function_check backup_${localremote}_${app_name}
backup_${localremote}_${app_name}
BACKUP_APPS_COMPLETED+=("${app_name}")
echo $"Backup ${app_name} completed"
done
}
function restore_apps {
localremote=$1
FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
RESTORE_APPS_COMPLETED=()
# for all the app scripts
for filename in $FILES
detect_installable_apps
get_apps_installed_names
for app_name in "${APPS_INSTALLED_NAMES[@]}"
do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
if [[ $RESTORE_APP == 'all' || $RESTORE_APP == "${app_name}" ]]; then
if [[ $(item_in_array ${app_name} ${RESTORE_APPS_COMPLETED[@]}) != 0 ]]; then
function_check app_is_installed
if [[ "$(app_is_installed $a)" == "1" ]]; then
RESTORE_APPS_COMPLETED+=("${app_name}")
function_check restore_${localremote}_${app_name}
restore_${localremote}_${app_name}
fi
fi
fi
echo $"Restoring ${app_name}"
function_check restore_${localremote}_${app_name}
restore_${localremote}_${app_name}
RESTORE_APPS_COMPLETED+=("${app_name}")
echo $"Restored ${app_name}"
done
}