improved README and removed problematic shell variables (which don't work on all systems) from the cron script
This commit is contained in:
parent
77aad0ac9c
commit
21e333cfde
2 changed files with 26 additions and 9 deletions
21
README.md
21
README.md
|
@ -1,3 +1,22 @@
|
|||
# SQLite Backup
|
||||
|
||||
A script which performs backups of an SQLite database on the local filesystem or in a Docker container and maintains dated backup instances as defined in its configuration, e.g. 24 hourly, 7 daily, 4 weekly, 12 monthly, and 7 yearly backups.
|
||||
A script which performs backups of an SQLite database on the local filesystem or in a Docker container and maintains dated backup instances as defined in its configuration, e.g. 24 hourly, 7 daily, 4 weekly, 12 monthly, and 7 yearly backups.
|
||||
|
||||
## Installation
|
||||
|
||||
There are 3 components to this script:
|
||||
|
||||
1. the backup BASH script itself, which has all the smarts,
|
||||
1. a sample of the .conf configuration file which defines the file paths and other details specific to your installation - like where the SQLite database actually is, or where to put the backup files - and
|
||||
1. a cron file which runs the script automatically when you tell it to run on your server.
|
||||
|
||||
To install:
|
||||
|
||||
* copy the code (either via a .zip or .tgz archive or via `git clone git@git.oeru.org:dave/sqlite-backup.git` onto the computer where you want to do the backups (uncompress it, of course, if required).
|
||||
* go into the directory `cd sqlite-backup` and create a copy of the configuration file: `cp sqlite_backup.conf-sample sqlite_backup.conf`
|
||||
* edit the sqlite_backup.conf file to set your values for BU_DIR, BU_FROOT, DB_DIR, DB_FILE, EMAIL, and EMAIL_SUBJ (to send email your server will need to be configured to send email) and DC_DIR and DC_CONT if desired.
|
||||
* make sure the directories you've specified above exist. If any of them doesn't, create it via `sudo mkdir -p full/path/you/specified`.
|
||||
* although it should already be executable (run `ls -l sqlite_backup` which should look like this: `-rwxrwxr-x 1 youruser youruser 5769 Feb 13 17:13 sqlite_backup` - if you have r-- or rw- without the "x", you need to make sure the sqlite_backup script is executable: `chmod a+x sqlite_backup` - you may need to add `sudo chmod a+x sqlite_backup`
|
||||
* edit sqlite_backup-cron to set the path to your script and adjust the timing if you like. Then copy it to /etc/cron.d by running `sudo cp sqlite_backup-cron /etc/cron.d` and it should "just work" at the appointed times.
|
||||
|
||||
You can test to make sure it works by running (from the script directory) `./sqlite_backup --hourly` and it should create an hourly backup in the directory you designated as BU_DIR with a filename starting with BU_FROOT.
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
USER=root
|
||||
DIR=/home/dave/sqlite_backups
|
||||
SCRIPT=dbbackup
|
||||
|
||||
#
|
||||
# run system backups
|
||||
#
|
||||
# hourly - at 5 minutes past mon-sat
|
||||
05 * * * * $USER $DIR/$SCRIPT --hourly
|
||||
05 * * * * root /home/data/scripts/sqlite-backup/sqlite_backup --hourly
|
||||
#
|
||||
# daily - at 7:30 pm, mon-sat
|
||||
30 19 * * * $USER $DIR/$SCRIPT --daily
|
||||
30 19 * * * root /home/data/scripts/sqlite-backup/sqlite_backup --daily
|
||||
#
|
||||
# weekly - at 7:30 pm, sun
|
||||
30 19 * * sun $USER $DIR/$SCRIPT --weekly
|
||||
30 19 * * sun root /home/data/scripts/sqlite-backup/sqlite_backup --weekly
|
||||
#
|
||||
# monthly - at 8:30 pm, on the first of the last of the month
|
||||
30 20 1 * * $USER $DIR/$SCRIPT --monthly
|
||||
30 20 1 * * root /home/data/scripts/sqlite-backup/sqlite_backup --monthly
|
||||
#
|
||||
# yearly - at 8:30 pm, on the first of January.
|
||||
30 20 1 1 * $USER $DIR/$SCRIPT --yearly
|
||||
30 20 1 1 * root /home/data/scripts/sqlite-backup/sqlite_backup --yearly
|
||||
|
|
Loading…
Reference in a new issue