-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackupscript.sh
28 lines (23 loc) · 940 Bytes
/
backupscript.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
#!/bin/bash
#Creates a backup config file and put it in the /var/ucs/ directory.
tmsh save /sys ucs /var/ucs/$(/bin/hostname)-$(date +\%Y-\%m-\%d).ucs
## Replace the YOUR_USERNAME, HOST_IP_OR_NAME and YOUR_PASSWORD as needed:
HOST="HOST_IP_OR_NAME"
USERNAME="YOUR_USERNAME"
PASSWORD="YOUR_PASSWORD"
## This section will create the connection to the SFTP server using the credentials provided above, change directory
## to the one where you want the file to be stored and put(upload) the backupt file into the the SFTP server.
expect <<EOF
spawn sftp $USERNAME@$HOST
expect "Password:"
send "$PASSWORD\n"
expect "sftp>"
send "cd /Users/SFTP_SERVER_FOLDER_PATH/\n"
expect "sftp>"
send "put /var/ucs/$(/bin/hostname)-$(date +\%Y-\%m-\%d).ucs\n"
expect "sftp>"
send "exit\n"
interact
EOF
## Optional: Uncomment the following line to delete the ucs file from the F5
#tmsh delete /sys ucs /var/ucs/$(/bin/hostname)-$(date +\%Y-\%m-\%d).ucs