"Fossies" - the Fresh Open Source Software Archive

Member "fsbackup-1.2pl2/contrib/psql_hourly/hourly_sql_backup.sh" (19 Oct 2007, 1068 Bytes) of package /linux/privat/old/fsbackup-1.2pl2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 # Ежечасный бэкап наиболее критичных данных на SQL сервере.
    3 # cron:
    4 # 53 */1 * * *   /usr/local/fsbackup/scripts/hourly_sql_backup.sh >/dev/null
    5 
    6 backup_database="testbase"
    7 
    8 usefull_table_list="table1 table2 table3"
    9        
   10 backup_path="/backup/.DB"
   11 
   12 backup_progdump_path="/usr/local/pgsql/bin"
   13 
   14 ############################################################################
   15 #/sbin/mount -u -w /backup
   16 #/bin/mount -o remount,rw /backup
   17 
   18 if [ ! -d "$backup_path" ]; then
   19     mkdir $backup_path
   20 fi
   21 
   22 backup_iteration=`date \+\%H`
   23 backup_path="$backup_path/$backup_iteration"
   24 
   25 if [ ! -d "$backup_path" ]; then
   26     mkdir $backup_path
   27 fi
   28 
   29 
   30 #-------------------------------------------------------------------------
   31 # Бэкап указанных баз для Postgresql
   32 
   33 
   34     for cur_table in $usefull_table_list; do
   35     echo "Dumping $cur_table..."
   36     ${backup_progdump_path}/pg_dump -a -t $cur_table $backup_database > $backup_path/$cur_table.sql
   37     /bin/chmod 0600 $backup_path/$cur_table.sql
   38     done
   39 
   40 #sync; sync; sync
   41 #sleep 5
   42 #/sbin/mount -u -w /backup
   43 #/bin/mount -o remount,rw /backup