fix: file changed as tar read it
This commit is contained in:
parent
8b15f665ef
commit
caaa607e94
3 changed files with 19 additions and 13 deletions
|
|
@ -106,12 +106,14 @@ ssh "${remote}" "docker exec --env-file '${env_file}' '${database_container}' pg
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
# Copy everything over to local machine.
|
# Copy everything over to local machine.
|
||||||
|
echo 'Info: Creating archive'
|
||||||
|
remote_archive="$( ssh "${remote}" 'mktemp' )"
|
||||||
|
ssh "${remote}" "tar -czf '${remote_archive}' ${remote_destination}"
|
||||||
echo 'Info: Copying to local machine.'
|
echo 'Info: Copying to local machine.'
|
||||||
ssh "${remote}" "tar -czf '/tmp/${backupfile}' ${remote_destination}"
|
scp "${remote}:${remote_archive}" "${local_destination}/${backupfile}"
|
||||||
scp "${remote}:/tmp/${backupfile}" "${local_destination}"
|
|
||||||
|
|
||||||
# Remove temporary destination on remote host.
|
# Remove temporary destination on remote host.
|
||||||
printf "Debug: Cleaning up '%s' on %s.\n" "${remote_destination}" "${remote}"
|
printf "Debug: Cleaning up '%s' on %s.\n" "${remote_destination},${remote_archive}" "${remote}"
|
||||||
ssh "${remote}" "rm -rf ${remote_destination}"
|
ssh "${remote}" "rm -rf ${remote_destination} ${remote_archive}"
|
||||||
|
|
||||||
echo 'Done'
|
echo 'Done'
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ set -e
|
||||||
|
|
||||||
if ! ssh "${remote}" "test -f '${env_file:=.env}'"; then
|
if ! ssh "${remote}" "test -f '${env_file:=.env}'"; then
|
||||||
>&2 printf "Error: Environment file does not exist: '%s'.\n" "${env_file}"
|
>&2 printf "Error: Environment file does not exist: '%s'.\n" "${env_file}"
|
||||||
>&2 printf "Debug: PWD: '%s'.\n" "$(ssh "${remote}" 'pwd')"
|
|
||||||
>&2 printf " Consider using the option '-e' to specify the correct environment file.\n"
|
>&2 printf " Consider using the option '-e' to specify the correct environment file.\n"
|
||||||
|
>&2 printf "Debug: PWD: '%s'.\n" "$(ssh "${remote}" 'pwd')"
|
||||||
usage 2
|
usage 2
|
||||||
elif ! ssh "${remote}" "test -r '${env_file:=.env}'"; then
|
elif ! ssh "${remote}" "test -r '${env_file:=.env}'"; then
|
||||||
>&2 printf "Error: Environment file is not readable: '%s'.\n" "${env_file}"
|
>&2 printf "Error: Environment file is not readable: '%s'.\n" "${env_file}"
|
||||||
|
|
@ -96,13 +96,15 @@ ssh "${remote}" "cp -a '/var/www/nextcloud/themes' '${remote_destination}'"
|
||||||
ssh "${remote}" 'sudo -u www-data /usr/bin/php /var/www/nextcloud/occ maintenance:mode --off'
|
ssh "${remote}" 'sudo -u www-data /usr/bin/php /var/www/nextcloud/occ maintenance:mode --off'
|
||||||
|
|
||||||
# Copy everything over to local machine.
|
# Copy everything over to local machine.
|
||||||
|
echo 'Info: Creating archive'
|
||||||
|
remote_archive="$( ssh "${remote}" 'mktemp' )"
|
||||||
|
ssh "${remote}" "tar -czf '${remote_archive}' ${remote_destination}"
|
||||||
echo 'Info: Copying to local machine.'
|
echo 'Info: Copying to local machine.'
|
||||||
ssh "${remote}" "tar -czf '/tmp/${backupfile}' ${remote_destination}"
|
scp "${remote}:${remote_archive}" "${local_destination}/${backupfile}"
|
||||||
scp "${remote}:/tmp/${backupfile}" "${local_destination}"
|
|
||||||
|
|
||||||
# Remove temporary destination on remote host.
|
# Remove temporary destination on remote host.
|
||||||
printf "Debug: Cleaning up '%s' on %s.\n" "${remote_destination}" "${remote}"
|
printf "Debug: Cleaning up '%s' on %s.\n" "${remote_destination},${remote_archive}" "${remote}"
|
||||||
ssh "${remote}" "rm -rf ${remote_destination}"
|
ssh "${remote}" "rm -rf ${remote_destination} ${remote_archive}"
|
||||||
|
|
||||||
# Backup cleanup
|
# Backup cleanup
|
||||||
# Only keep 30 days of backups
|
# Only keep 30 days of backups
|
||||||
|
|
|
||||||
|
|
@ -97,13 +97,15 @@ for file in 'attachments' 'sends' 'rsa_key.pem' 'rsa_key.pub.pem'; do # 'config
|
||||||
done
|
done
|
||||||
|
|
||||||
# Copy everything over to local machine.
|
# Copy everything over to local machine.
|
||||||
|
echo 'Info: Creating archive'
|
||||||
|
remote_archive="$( ssh "${remote}" 'mktemp' )"
|
||||||
|
ssh "${remote}" "tar -czf '${remote_archive}' ${remote_destination}"
|
||||||
echo 'Info: Copying to local machine.'
|
echo 'Info: Copying to local machine.'
|
||||||
ssh "${remote}" "tar -czf '${remote_destination}/${backupfile}' --exclude=${backupfile} ${remote_destination}"
|
scp "${remote}:${remote_archive}" "${local_destination}/${backupfile}"
|
||||||
scp "${remote}:${remote_destination}/${backupfile}" "${local_destination}"
|
|
||||||
|
|
||||||
# Remove temporary destination on remote host.
|
# Remove temporary destination on remote host.
|
||||||
printf "Debug: Cleaning up '%s' on %s.\n" "${remote_destination}" "${remote}"
|
printf "Debug: Cleaning up '%s' on %s.\n" "${remote_destination},${remote_archive}" "${remote}"
|
||||||
ssh "${remote}" "rm -rf ${remote_destination}"
|
ssh "${remote}" "rm -rf ${remote_destination} ${remote_archive}"
|
||||||
|
|
||||||
# Backup cleanup
|
# Backup cleanup
|
||||||
# Only keep 30 days of backups, seems about right.
|
# Only keep 30 days of backups, seems about right.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue