2021-01-07 15:22:20 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Show help page
|
|
|
|
if [ "$1" = "-h" ]
|
|
|
|
then
|
|
|
|
echo "system-backup <option>"
|
|
|
|
echo
|
|
|
|
echo "If no options are specified it will use default"
|
|
|
|
echo
|
|
|
|
echo "Options:"
|
|
|
|
echo
|
2021-01-07 23:37:25 +01:00
|
|
|
echo "-d [USB Drive]"
|
2021-01-07 15:22:20 +01:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Initialize variables
|
2021-01-07 23:37:25 +01:00
|
|
|
backup_dir="/mnt/USB/Backup/"$(date +'%Y/%m/%d')
|
2021-01-07 15:22:20 +01:00
|
|
|
backup_dir_remote="/media/backup/games/"$(date +'%Y/%m/%d')
|
|
|
|
minecraft_dir="/media/games/bukkit"
|
2021-01-22 12:56:25 +01:00
|
|
|
#csgo_dir="/var/"
|
|
|
|
remote_ip="192.168.178.8"
|
2021-01-07 15:22:20 +01:00
|
|
|
|
2021-01-07 23:37:25 +01:00
|
|
|
if [ "$1" = "-d" ]
|
|
|
|
then
|
|
|
|
sudo mkdir /mnt/USB/
|
|
|
|
sudo mount $2 /mnt/USB/
|
|
|
|
sudo mkdir -p $backup_dir"/mc"
|
|
|
|
sudo mkdir $backup_dir"/cs-go"
|
|
|
|
sudo screen -dmS backup -t backup bash -c "rsync -Aarz --progress -e ssh $minecraft_dir/ $backup_dir/mc;
|
|
|
|
rsync -Aarz --progress -e ssh $csgo_dir $backup_dir/cs-go/"
|
|
|
|
else
|
|
|
|
# Create remote directory
|
|
|
|
sudo ssh backup-user@$remote_ip mkdir -p $backup_dir_remote/cs-go mkdir $backup_dir_remote/mc
|
|
|
|
# copy the shit over
|
2021-01-22 12:56:25 +01:00
|
|
|
sudo screen -dmS backup -t backup bash -c "
|
|
|
|
rsync -Aarz --progress --exclude={$minecraft_dir/logs,$minecraft_dir/crash-reports} -e ssh $minecraft_dir/ backup-user@$remote_ip:$backup_dir_remote/mc;"
|
|
|
|
#rsync -Aarz --progress -e ssh $csgo_dir backup-user@$remote_ip:$backup_dir_remote/cs-go/
|
2021-01-07 23:37:25 +01:00
|
|
|
fi
|