diff --git a/scripts/deploy-nas.ps1 b/scripts/deploy-nas.ps1 index 80206fd..efc5e61 100644 --- a/scripts/deploy-nas.ps1 +++ b/scripts/deploy-nas.ps1 @@ -122,13 +122,13 @@ if [ -d "`$previous" ]; then fi fi -find "`$remote_root" -maxdepth 1 -type d \( -name ".`$site_name`_deploy_*" -o -name "`$site_name`_deploy_*" -o -name ".`$site_name`_previous_*" \) -exec rm -rf -- {} + +find "`$remote_root" -maxdepth 1 -type d \( -name ".`${site_name}_deploy_*" -o -name "`${site_name}_deploy_*" -o -name ".`${site_name}_previous_*" \) -exec rm -rf -- {} + if [ "`$retention" -eq 0 ]; then - find "`$remote_root" -maxdepth 1 -type d -name "`$site_name.backup-*" -exec rm -rf -- {} + + find "`$remote_root" -maxdepth 1 -type d -name "`${site_name}.backup-*" -exec rm -rf -- {} + else keep_count=`$retention - find "`$remote_root" -maxdepth 1 -type d -name "`$site_name.backup-*" -printf '%f\n' | sort -r | tail -n +`$((keep_count + 1)) | while IFS= read -r old_backup; do + find "`$remote_root" -maxdepth 1 -type d -name "`${site_name}.backup-*" -printf '%f\n' | sort -r | tail -n +`$((keep_count + 1)) | while IFS= read -r old_backup; do [ -n "`$old_backup" ] && rm -rf -- "`$remote_root/`$old_backup" done fi @@ -136,7 +136,7 @@ fi printf 'Deployed %s at %s\n' "`$site_name" "`$site" printf 'Backup retention: %s\n' "`$retention" printf 'Remaining site directories:\n' -find "`$remote_root" -maxdepth 1 -type d -name "*`$site_name*" -printf '%f\n' | sort +find "`$remote_root" -maxdepth 1 -type d -name "*`${site_name}*" -printf '%f\n' | sort "@ ssh -o BatchMode=yes -o ConnectTimeout=8 -i $SshKey -p $SshPort $userHost $installRemote