root/feedmelinks/bin/backup-dump-tables.sh

Revision 1405, 0.7 kB (checked in by jm3, 2 years ago)

updated configuration setup script to also build our crontab file, so now there are like, ZERO passwords or paths coded anywhere

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/bin/sh
2
3 . env.sh
4
5 # db auth: (all read in from from env.sh)
6 db_u=`get_database_user`
7 db=`get_database_name`
8 db_p=`get_database_password`
9
10 root=`get_webserver_root`
11
12 # optional directory prefix, else drop the backup in ~:
13 subdir=$1
14
15 dumpdir=`date +%Y-%m-%d`_db_dump
16
17 if [ -n "$subdir" ] ;
18 then
19         startdir=$subdir
20 else
21         startdir=$root/_backups
22 fi
23
24 mkdir -p $startdir
25
26 tables="links links_tags_xref tags users"
27
28 cd $startdir
29 mkdir -p $dumpdir
30 cd $dumpdir
31 touch LAST_DATABASE_DUMP_FROM_`date | sed 's/ /_/g'`
32 for t in $tables
33 do
34         mysqldump -u $db_u -p$db_p $db $t > $t.sql
35 done
36
37 cd ..
38 gtar cvz $dumpdir -f $dumpdir.tgz
39 rm -rf $dumpdir
40
41 gpg -r jm3 --encrypt-files $dumpdir.tgz
42 rm $dumpdir.tgz
43
44 echo
45 echo dumped, compressed, and encrypted tables successfully
46 exit 0
Note: See TracBrowser for help on using the browser.