Fix backup issues
This commit is contained in:
parent
243b7dacc8
commit
6b1078057a
2 changed files with 21 additions and 17 deletions
|
@ -25,6 +25,7 @@ while getopts ":e:" option; do
|
|||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
# Check arguments.
|
||||
|
||||
|
@ -59,11 +60,11 @@ docker exec "${base_container}" php occ maintenance:mode --on
|
|||
# Database backup
|
||||
echo 'Backing up database'
|
||||
host_database_backupfile="${destination}/${database_backupfile}"
|
||||
docker exec --env-file "${env_file:='./nextcloud.env'}" "${database_container}" pg_dump 'nextcloud' -cwv -h 'localhost' -U 'nextcloud' > "${host_database_backupfile}"
|
||||
docker exec --env-file "${env_file:=.env}" "${database_container}" pg_dump 'nextcloud' -cwv -h 'localhost' -U 'nextcloud' > "${host_database_backupfile}"
|
||||
|
||||
# Files backup
|
||||
for file in 'config' 'themes'; do
|
||||
printf 'Copying %s\n' "${file}"
|
||||
printf "Copying %s\n" "${file}"
|
||||
docker cp -a "${base_container}":"/var/www/html/${file}" "${destination}"
|
||||
done
|
||||
|
||||
|
@ -72,7 +73,7 @@ docker exec "${base_container}" php occ maintenance:mode --off
|
|||
|
||||
# Backup cleanup
|
||||
# Only keep 30 days of backups
|
||||
printf 'Clean up old database backups'
|
||||
printf "Clean up old database backups.\n"
|
||||
find "${destination}" -name '*sqlbkp*' -type f -mtime +30 -print -delete
|
||||
|
||||
printf 'Done'
|
||||
printf "Done\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue