List:General Discussion« Previous MessageNext Message »
From:Charles Hauser Date:March 19 2004 4:50pm
Subject:server backups
View as plain text  
All,

I'm new to mysql.

I'm interested in writing a cron job to backup mysql that will:
 - Backup all the global information first (users and groups, typically)
 - Backup each database independently (not dumpall)



For postgres I can dump:

 - globals
        pg_dumpall -U $PG_ADMIN -g > $PG_BACKUP_DIR/globals.sql

 - databases

for database in $(psql -l -t -d template1 -U $PG_ADMIN | cut -f1 -d'|')
; do
    if [ $database = "template0" ] ; then
        continue  # we cannot backup or restore this database
    fi
                                                                                          
    
    # actually dump the database to a pg_dump "custom" file format...
    syslog debug "Attempting to backup database $database."
    pg_dump -f $PG_BACKUP_DIR/$database.custom -Fc -U $PG_ADMIN
$database
    if [ $? != 0 ] ; then
        syslog crit "CRITICAL Failed to backup database $database."
    else
        syslog info "Backed up database $database."
    fi
                                                                                          
    
done



Charles

Thread
server backupsCharles Hauser19 Mar
  • Re: server backupsKeith Keller19 Mar