-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup-pi.sh
executable file
·65 lines (52 loc) · 1.16 KB
/
backup-pi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# Linux FTP Backup Script
# Version: 1.0
# Script by: Pietro Marangon
# Skype: pe46dro
# Email: [email protected]
clean_backup() {
rm -f ./"$FILE"
echo 'Local Backup Removed'
}
########################
# Edit Below This Line #
########################
# FTP Login Data
USERNAME="USERNAME HERE"
PASSWORD="PASSWORD HERE"
SERVER="IP HERE"
PORT="REMOTE SERVER PORT"
#Directory where thing to backup is located
DIR="/root"
#Remote directory where the backup will be placed
REMOTEDIR="./"
#Filename of backup file to be transfered DON'T WRITE EXTENSION (.tar/.zip/ecc...)
FILE="BACKUP_NAME"
#Transfer type
#1=FTP
#2=SFTP
TYPE=1
##############################
# Don't Edit Below This Line #
##############################
d=$(date --iso)
FILE=$FILE"_"$d".tar.gz"
tar -czvf ./"$FILE" $DIR
echo 'Tar Complete'
if [ $TYPE -eq 1 ]
then
ftp -n -i $SERVER $PORT <<EOF
user $USERNAME $PASSWORD
binary
put $FILE $REMOTEDIR/$FILE
quit
EOF
elif [ $TYPE -eq 2 ]
then
rsync --rsh="sshpass -p $PASSWORD ssh -p $PORT -o StrictHostKeyChecking=no -l $USERNAME" $FILE $SERVER:$REMOTEDIR
else
echo 'Please select a valid type'
fi
echo 'Remote Backup Complete'
clean_backup
#END