X-Git-Url: https://git.p6c8.net/nextcloud-backup-restore.git/blobdiff_plain/de265748263b2733974ce8df0c94c081a1ba660b..refs/remotes/upstream/auto-setup:/NextcloudBackup.sh?ds=sidebyside diff --git a/NextcloudBackup.sh b/NextcloudBackup.sh index ce9601a..47abd13 100644 --- a/NextcloudBackup.sh +++ b/NextcloudBackup.sh @@ -3,7 +3,7 @@ # # Bash script for creating backups of Nextcloud. # -# Version 1.0.0 +# Version 2.0.0 # # Usage: # - With backup directory specified in the script: ./NextcloudBackup.sh @@ -26,8 +26,6 @@ if [ -z "$backupMainDir" ]; then backupMainDir='/media/hdd/nextcloud_backup' fi -echo "Backup directory: $backupMainDir" - currentDate=$(date +"%Y%m%d_%H%M%S") # The actual directory of the current backup - this is a subdirectory of the main directory above with a timestamp @@ -50,7 +48,7 @@ webserverServiceName='nginx' # TODO: Your web server user webserverUser='www-data' -# TODO: The name of the database system (ome of: mysql, mariadb, postgresql) +# TODO: The name of the database system (one of: mysql, mariadb, postgresql) databaseSystem='mariadb' # TODO: Your Nextcloud database name @@ -65,7 +63,7 @@ dbPassword='mYpAsSw0rd' # TODO: The maximum number of backups to keep (when set to 0, all backups are kept) maxNrOfBackups=0 -# TODO: Ignore updater's backup directory in the data directory to safe space +# TODO: Ignore updater's backup directory in the data directory to save space # Set to true to ignore the backup directory ignoreUpdaterBackups=false @@ -103,9 +101,19 @@ function CtrlC() { echo "Maintenance mode still enabled." fi + echo "Starting web server..." + systemctl start "${webserverServiceName}" + echo "Done" + echo + exit 1 } +# +# Print information +# +echo "Backup directory: ${backupMainDir}" + # # Check for root # @@ -187,11 +195,11 @@ if [ "${databaseSystem,,}" = "mysql" ] || [ "${databaseSystem,,}" = "mariadb" ]; echo "Done" echo -elif [ "${databaseSystem,,}" = "postgresql" ]; then +elif [ "${databaseSystem,,}" = "postgresql" ] || [ "${databaseSystem,,}" = "pgsql" ]; then echo "Backup Nextcloud database (PostgreSQL)..." if ! [ -x "$(command -v pg_dump)" ]; then - errorecho "ERROR:PostgreSQL not installed (command pg_dump not found)." + errorecho "ERROR: PostgreSQL not installed (command pg_dump not found)." errorecho "ERROR: No backup of database possible!" else PGPASSWORD="${dbPassword}" pg_dump "${nextcloudDatabase}" -h localhost -U "${dbUser}" -f "${backupdir}/${fileNameBackupDb}"