User Tools

Site Tools


scripting:mariadb-backup.sh

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
scripting:mariadb-backup.sh [2015-03-09 01:17] – .my.cnf explanation gabrielscripting:mariadb-backup.sh [2019-08-10 14:58] – change title gabriel
Line 1: Line 1:
-====== mariadb-backup.sh - a simple script to dump and rotate MariaDB backups  ======+====== mariadb-backup.sh ======
  
-This script is useful to dump a MariaDB (or MySQL) database to disk and to rotate through a given number of backups.  It supports two command line arguments:+This script can be used to dump a MariaDB (or MySQL) database to disk and to rotate through a given number of backups.  It supports two command line arguments:
  
   * **-q** run silently (for use in crontabs or other non-interactive settings)   * **-q** run silently (for use in crontabs or other non-interactive settings)
   * **-k N** number of recent backups to keep (default is 7)   * **-k N** number of recent backups to keep (default is 7)
  
-The script assumes that backup user has a ''~/.my.cnf'' file storing the database connection (or passwordless access to the database as the current userid).+The script assumes that backup user has a ''~/.my.cnf'' file storing the database connection (or passwordless access to the database as the current userid).  It's a good idea to create a MariaDB user that has the appropriate permissions for dumping databases instead of running this script as the unix root user.
  
 <code bash> <code bash>
Line 13: Line 13:
 # mariadb-backup.sh - a simple script to dump and rotate MariaDB backups # mariadb-backup.sh - a simple script to dump and rotate MariaDB backups
 # #
-# Copyright (c) 2011 Gabriel M. O'Brien+# Copyright (c) 2015 Gabriel M. O'Brien
 # #
 # Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
Line 79: Line 79:
 # remove old backups # remove old backups
 cd $backup_root cd $backup_root
 +
 +# create a link to current backup
 +rm -f latest && ln -s ${stamp} latest
  
 # find out how many backups are in this directory # find out how many backups are in this directory
scripting/mariadb-backup.sh.txt · Last modified: 2019-08-10 17:26 by gabriel