-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.sh
More file actions
30 lines (23 loc) · 670 Bytes
/
dump.sh
File metadata and controls
30 lines (23 loc) · 670 Bytes
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
#!/bin/bash
#dont forget to set these below or else this script will not work
database_name=""
database_user=""
database_password=""
#details for SCP
remote_host=""
remote_host_username=""
remote_host_password=""
ssh_port=""
# Define a timestamp function
timestamp() {
date +%s
}
# lets dump the DB now
filename=$(timestamp)
remote_filename=$filename.sql
mysqldump -u $database_user -p$database_password $database_name > $filename.sql
# lets scp this!
sshpass -p "$remote_host_password" scp -P $ssh_port $remote_filename $remote_host_username@$remote_host:/root
#lets delete the local backup file which we created above
shred -uvz $remote_filename
echo "Done!"