Expanded with network as standart
This commit is contained in:
parent
50d2642aa4
commit
99fbed07e5
@ -1,39 +1,58 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
backup_dir="/mnt/USB/Backup/"$(date +'%Y/%m/%d')
|
# Show help page
|
||||||
|
|
||||||
cd /var/www/nextcloud
|
|
||||||
sudo -u www-data php occ maintenance:mode --on
|
|
||||||
|
|
||||||
if [ "$1" = "-h" ]
|
if [ "$1" = "-h" ]
|
||||||
then
|
then
|
||||||
echo "system-backup <option> [USB Dir]"
|
echo "system-backup <option>"
|
||||||
echo
|
echo
|
||||||
echo "If no options are specified it will use default"
|
echo "If no options are specified it will use default"
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo
|
echo
|
||||||
#echo "-d [USB Dir] [directory to back up]"
|
#echo "-d [USB Dir]"
|
||||||
#echo "-n use SCP instead of USB"
|
echo
|
||||||
echo
|
echo
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "-d" ]
|
# if [ "$1" = "-d" ]
|
||||||
then
|
# then
|
||||||
sudo mount "$2"
|
# sudo mount "$2"
|
||||||
sudo mkdir -p $backup_dir"/nextcloud"
|
# sudo mkdir -p $backup_dir"/nextcloud"
|
||||||
sudo mkdir $backup_dir"/mysql"
|
# sudo mkdir $backup_dir"/mysql"
|
||||||
sudo mkdir $backup_dir"/gitea"
|
# sudo mkdir $backup_dir"/gitea"
|
||||||
sudo screen -dmS backup -t backup rsync -Aavx /var/www/nextcloud/ $backup_dir"/nextcloud"
|
# sudo screen -dmS backup -t backup rsync -Aav --progress $nextcloud_dir/ $backup_dir"/nextcloud"
|
||||||
else
|
# else
|
||||||
sudo mount /dev/sdb0
|
# sudo mount /dev/sdb0
|
||||||
sudo mkdir /mnt/USB/Backup-whole-System/
|
# sudo mkdir /mnt/USB/Backup-whole-System/
|
||||||
sudo screen -dmS backup -t backup
|
# sudo screen -dmS backup -t backup
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
if [ "$1" = "-n" ]
|
# Initialize variables
|
||||||
then
|
backup_dir="/mnt/USB/Backup/"$(date +'%Y/%m/%d')
|
||||||
sudo screen -dmS backup -t backup
|
backup_dir_remote="/media/backup/"$(date +'%Y/%m/%d')
|
||||||
exit 0
|
nextcloud_dir="/var/www/nextcloud"
|
||||||
fi
|
gitea_dir="/var/"
|
||||||
|
remote_ip="192.168.178.48"
|
||||||
|
|
||||||
|
# Back the fuck up bro...
|
||||||
|
# Shuting down services for backup
|
||||||
|
cd $nextcloud_dir
|
||||||
|
sudo -u www-data php occ maintenance:mode --on
|
||||||
|
sudo apache2 stop
|
||||||
|
sudo mysqldump --single-transaction nextcloud > /tmp/mysqldump/nextcloud.sql
|
||||||
|
cd /usr/local/bin
|
||||||
|
sudo -u git ./gitea dump -c /etc/gitea/app.ini
|
||||||
|
|
||||||
|
sudo ssh backup@$remote_ip sudo mkdir -p $backup_dir_remote
|
||||||
|
|
||||||
|
sudo screen -dmS backup -t backup bash -c "rsync -Aavr --progress -e ssh $nextcloud_dir backup-user@$remote_ip:$backup_dir_remote/nextcloud;
|
||||||
|
rsync -Aavr --progress -e ssh $gitea_dir backup-user@$remote_ip:$backup_dir_remote/gitea;
|
||||||
|
rsync -Aavr --progress -e ssh /tmp/nextcloud.sql backup-user@$remote_ip:$backup_dir_remote/mysql/;
|
||||||
|
rsync -Aavr --progress -e ssh /tmp/gitea.sql backup-user@$remote_ip:$backup_dir_remote/mysql/"
|
||||||
|
|
||||||
|
#To-Do
|
||||||
|
# gitea dump permissions
|
||||||
|
# rsync test
|
||||||
|
# cleanup
|
||||||
|
# starting back up
|
Loading…
Reference in New Issue
Block a user