fix: file changed as tar read it

This commit is contained in:
Tibo De Peuter 2025-11-23 15:26:25 +01:00
parent 8b15f665ef
commit caaa607e94
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
3 changed files with 19 additions and 13 deletions

View file

@ -106,12 +106,14 @@ ssh "${remote}" "docker exec --env-file '${env_file}' '${database_container}' pg
# TODO
# 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.'
ssh "${remote}" "tar -czf '/tmp/${backupfile}' ${remote_destination}"
scp "${remote}:/tmp/${backupfile}" "${local_destination}"
scp "${remote}:${remote_archive}" "${local_destination}/${backupfile}"
# Remove temporary destination on remote host.
printf "Debug: Cleaning up '%s' on %s.\n" "${remote_destination}" "${remote}"
ssh "${remote}" "rm -rf ${remote_destination}"
printf "Debug: Cleaning up '%s' on %s.\n" "${remote_destination},${remote_archive}" "${remote}"
ssh "${remote}" "rm -rf ${remote_destination} ${remote_archive}"
echo 'Done'