-
Notifications
You must be signed in to change notification settings - Fork 1
/
dump-n-send.sh
executable file
·32 lines (28 loc) · 1.19 KB
/
dump-n-send.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
#!/bin/bash
DATE=$(date)
DUMPDATE=$(date +%F)
mysql_user=neklsreports
mysql_pass=xxxxxxx
mysql_port=3306
hostname=heh.ec2.liblime.com
kohadb=koha_nekls
savepath=/home/liz/dbdumps/
sftpuser=nekls
sftppass=xxxxxxxx
sftphost=67.23.29.188
echo "Dumping Database started at $DATE" > message.txt
mysqldump -u$mysql_user -p$mysql_pass -h$hostname -P$mysql_port $kohadb --ignore-table=koha_nekls.sessions --ignore-table=koha_nekls.zebraqueue --ignore-table=koha_nekls.message_queue --ignore-table=koha_nekls.action_logs --skip-lock-tables > harleydb-production-"$DUMPDATE".sql
DATE=$(date)
echo "Zipping Database started at $DATE" >>message.txt
gzip $savepath/harleydb-production-"$DUMPDATE".sql
DATE=$(date)
echo "FTP commenced at $DATE" >>message.txt
lftp -u nekls,N3KLS sftp://$sftphost <<EOF
put $savepath/harleydb-production-"$DUMPDATE".sql.gz
bye
EOF
DATE=$(date)
echo "DB Dump and upload completed on $DATE. Name of file placed on SFTP server is harleydb-production"$DUMPDATE"" >> message.txt
mutt -s "DB Dump Completed" $recipients < message.txt
mysqldump -u$mysql_user -p$mysql_pass -h$hostname -p$mysql_host $kohadb --table=action_logs > production_actionlogs"$DUMPDATE".sql