System-Backup/system-backup
2021-01-06 22:33:41 +01:00

39 lines
921 B
Bash

#!/bin/bash
backup_dir="/mnt/USB/Backup/"$(date +'%Y/%m/%d')
cd /var/www/nextcloud
sudo -u www-data php occ maintenance:mode --on
if [ "$1" = "-h" ]
then
echo "system-backup <option> [USB Dir]"
echo
echo "If no options are specified it will use default"
echo
echo "Options:"
echo
#echo "-d [USB Dir] [directory to back up]"
#echo "-n use SCP instead of USB"
echo
exit 0
fi
if [ "$1" = "-d" ]
then
sudo mount "$2"
sudo mkdir -p $backup_dir"/nextcloud"
sudo mkdir $backup_dir"/mysql"
sudo mkdir $backup_dir"/gitea"
sudo screen -dmS backup -t backup rsync -Aavx /var/www/nextcloud/ $backup_dir"/nextcloud"
else
sudo mount /dev/sdb0
sudo mkdir /mnt/USB/Backup-whole-System/
sudo screen -dmS backup -t backup
fi
if [ "$1" = "-n" ]
then
sudo screen -dmS backup -t backup
exit 0
fi