-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskrypt.sh
56 lines (54 loc) · 1.15 KB
/
skrypt.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
#!/bin/sh
#Entering basic information
echo "Choose file/folder that you want to backup"
read file
echo "Do backup [1]Local or [2]Remote(FTP)"
read letter
if [ $letter -eq 2 ]; then
echo "Please insert your FTP data"
echo "FTP HOST:"
read host
echo "USERNAME"
read username
echo "PASSWORD"
read password
fi
echo "Choose method of backup"
echo "[1].ZIP [2].TAR.GZ"
read method
NOWDATE=`date +%d%m%y`
#Staring packing with choosen method
if [ $method -eq 2 ]; then
tar -cvzf /usr/backup/$NOWDATE.tar.gz $file
fi
if [ $method -eq 1 ]; then
zip -R /usr/backup/$NOWDATE.zip $file
fi
echo Packing complete
#Connecting to FTP server and uploading files
if [ $letter -eq 2 ]; then
if [ $method -eq 1 ]; then
ftp -n -i $host <<EOF
user $username $password
put /usr/backup/$NOWDATE.zip $NOWDATE.zip
!
EOF
fi
if [ $method -eq 2 ]; then
ftp -n -i $host <<EOF
user $username $password
put /usr/backup/$NOWDATE.tar.gz $NOWDATE.tar.gz
!
EOF
fi
fi
#Moving packed files to choosen location
if [ $letter -eq 1 ]; then
echo "Choose your backup folder"
read folder
mv /usr/backup/$NOWDATE.tar.gz &folder
fi
echo COMPLETE
#Test host infug.net78.net
#Test username a4860405
#Test password haslo6