2021-01-06 21:08:40 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-01-06 22:33:41 +01:00
|
|
|
backup_dir="/mnt/USB/Backup/"$(date +'%Y/%m/%d')
|
|
|
|
|
|
|
|
cd /var/www/nextcloud
|
|
|
|
sudo -u www-data php occ maintenance:mode --on
|
|
|
|
|
2021-01-06 21:08:40 +01:00
|
|
|
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
|
2021-01-06 22:33:41 +01:00
|
|
|
#echo "-d [USB Dir] [directory to back up]"
|
|
|
|
#echo "-n use SCP instead of USB"
|
2021-01-06 21:08:40 +01:00
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "-d" ]
|
|
|
|
then
|
2021-01-06 22:33:41 +01:00
|
|
|
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
|
2021-01-06 21:08:40 +01:00
|
|
|
sudo screen -dmS backup -t backup
|
|
|
|
exit 0
|
|
|
|
fi
|