Created
May 24, 2019 09:47
-
-
Save lucarin91/975948e0a26ca84275a7d052c68f3c16 to your computer and use it in GitHub Desktop.
Simple script for backup Nextcloud data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -x | |
NC_PATH="/var/www/nextcloud" | |
DST_PATH="/tmp" | |
DATE=$(date +"%Y%m%d") | |
# start maintenance | |
sudo -u www-data php "$NC_PATH/occ" maintenance:mode --on | |
# backup folder | |
tar -czf "$DST_PATH/nextcloud-dirbkp_$DATE.tar.gz" -C "$(dirname $NC_PATH)" "$(basename $NC_PATH)" | |
# backup database | |
sudo mysqldump --single-transaction -u[user] -p[password] [database] > "$DST_PATH/nextcloud-sqlbkp_$DATE.bak" | |
# stop maintenance | |
sudo -u www-data php "$NC_PATH/occ" maintenance:mode --off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment