]> git.p6c8.net - nextcloud-backup-restore.git/blobdiff - NextcloudBackup.sh
Backup dir can be specified as parameter
[nextcloud-backup-restore.git] / NextcloudBackup.sh
index fb20a47877a3c231d4d2f586297643dfd2889687..4c95f10ca6a8d92fb77601a8270a214f44dac141 100644 (file)
 #
 
 # Variables
+backupMainDir=$1
+
+if [ -z "$backupMainDir" ]; then
+       # TODO: The directory where you store the Nextcloud backups (when not specified by args)
+    backupMainDir="/mnt/Share/NextcloudBackups"
+fi
+
+echo "Backup directory: $backupMainDir"
+
 currentDate=$(date +"%Y%m%d_%H%M%S")
-# TODO: The directory where you store the Nextcloud backups
-backupMainDir="/mnt/Share/NextcloudBackups"
 # The actual directory of the current backup - this is a subdirectory of the main directory above with a timestamp
 backupdir="${backupMainDir}/${currentDate}/"
 # TODO: The directory of your Nextcloud installation (this is a directory under your web root)
@@ -123,7 +130,11 @@ echo
 # Backup DB
 #
 echo "Backup Nextcloud database..."
+# MySQL/MariaDB:
 mysqldump --single-transaction -h localhost -u "${dbUser}" -p"${dbPassword}" "${nextcloudDatabase}" > "${backupdir}/${fileNameBackupDb}"
+
+# PostgreSQL (uncomment if you are using PostgreSQL as Nextcloud database)
+#PGPASSWORD="${dbPassword}" pg_dump "${nextcloudDatabase}" -h localhost -U "${dbUser}" -f "${backupdir}/${fileNameBackupDb}"
 echo "Done"
 echo
 

patrick-canterino.de