Updated: 2018/08/19
O/S : Aix,Linux,MacOS

NAME   -   Backup one or all MySQL/MariaDB Databases present on the system.

SYNOPSIS     [ -u -v -h  ]    [ -d   0-9  ]    [ -b   backup_dir  ]    [ -n   dbname  ]   

  • This script is mainly use to backup the SADMIN database, but it can be use to backup one or all MySQL/MariaDB Databases present on a system. Default is to backup all database, except the one specified in the DBEXCLUDE variable find in the script.
            # Database to exclude from backup, separate each name by the pipe symbol '|'
            DBEXCLUDE="information_schema|performance_schema"  ; export DBEXCLUDE
  • We recommend running this script daily, from the crontab so you don't miss weekly,monthly and yearly backup day.
  • For each database that's backup a compress sql file is produced. The file name follow this pattern "databaseName_YYYY_MM_DD_HH_MM_SS.sql.gz".
    For example, "sadmin_2018_07_13_05_46_25_Friday.sql.gz" is the backup file for the 'sadmin' database taken at 05:46:25AM on July the 13th 2018.
  • The default backup directory structure where the backup will be created is "${SADMIN}/dat/dbb", but you can specify the backup directory of your choice with the '-b' command line option.
  • In the backup directory, backup are group by type: 'daily','weekly','monthly','yearly' and the 'latest' directory.
    In each of these directories, there is a sub-directory for each of the database that's backup.
    If you're looking for the latest Database backup, go in the 'latest' sub-directory, the more recent backup will always be there.
  • After a couple of months, the backup directory structure should look similar to the one below.
    • We have 8 'daily' backups (This is the default).
    • The 'latest' directory contain link to the most recent backup.
    • The 'monthly' is taken on the first of each month (Default). We also decided to keep 13 copies of the monthly backup (Default).
    • Weekly backup is done every Friday (Default) and we decided to do it every Friday (Default).
    • The 'yearly' backup, will be taken on the 31th of December (Default) of each year (not done yet) and the default is to keep 4 copies of yearly backup.
  • Content of directory $SADMIN/dat/dbb

  • If you wish to change the value of any of the variables below, it would be advisable to copy the script to the user directory (${SADMIN}/usr/bin), so it's not modified by a future version of this script. In future version, we will allow these variables to be specify on the command line , so that we all use the same script and be sure to benefit of the features that new version will offer.
  • Copy script to $SADMIN/usr/bin when changing default value

  • Take a look at the log that is produced when the script is run.


-b [backupDir]
Specify backup destination directory (Default is $SADMIN/dat/dbb).
-n [dbname]
Specify the database name to backup
Produce an uncompressed backup (Default is compress).
Specify debug level (0-9).
Value of 0 indicate that no debug information is to be displayed.
Display this help and exit.
Output version information and exit.

[0]    An exit status of zero indicates success
[1]    Failure is indicated by a nonzero value, typically ‘1’.

Jacques Duplessis (
Any suggestions or bug report can be sent at

Copyright © 2018 Free Software Foundation, Inc. License GPLv3+:
    - GNU GPL version 3 or later
This is free software, you are free to change and redistribute it.
There is NO WARRANTY to the extent permitted by law.

SEE ALSO   (Backup directories and files)


Copyright © 2015-2019 - - Suggestions, Questions or Report a problem at