39 lines
1.2 KiB
Bash
39 lines
1.2 KiB
Bash
#!/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
|
|
echo "-d [USB Drive]"
|
|
echo
|
|
echo
|
|
exit 0
|
|
fi
|
|
|
|
# Initialize variables
|
|
backup_dir="/mnt/USB/Backup/"$(date +'%Y/%m/%d')
|
|
backup_dir_remote="/media/backup/games/"$(date +'%Y/%m/%d')
|
|
minecraft_dir="/media/games/bukkit"
|
|
csgo_dir="/var/"
|
|
remote_ip="192.168.178."
|
|
|
|
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
|
|
sudo screen -dmS backup -t backup bash -c "rsync -Aarz --progress -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/"
|
|
fi |