diff --git a/docs/30_Configuration/10_Database.md b/docs/30_Configuration/10_Database.md index ef1a17aab4e944b1f2bc1293c1163fe4fa3317d3..971f0168d32cffa3b6db93e81ef5f2bb103034fb 100644 --- a/docs/30_Configuration/10_Database.md +++ b/docs/30_Configuration/10_Database.md @@ -1,46 +1,31 @@ +# Basic settings for database backups # -# Basic settings # +There are 2 required values in the jobs/backup.job -There are 2 defaults: - -``` +```text dir-localdumps = /var/iml-backup keep-days = 7 ``` -## dir-localdumps ## - -{string} - -The target directory for local dumps. It is used by - -* the database dump scripts -* the transfer script to store the client backups -* the restore script +This defines the backup target for sql dumps and how long they will be kept locally. -Below that one a directory for the service will be generated; inside that one the database dumbs with scheme name and timestamp, i.e. +There is an optional value to define the target directory for archived dumps. This value is used for couchdb2 only. - /var/iml-backup/mysql/mydatabase__20190827-2300.sql.gz +`dir-dbarchive = /var/localdumps/archive` -## keep-days ## +see [backup.job](50_File_backup.job.md) -{integer} +## Backup sqlite ## -The number of days how long to keep dumps locally. +Sqlite files can be located anywhere in the filesystem. That's why the +cannot be located with an auto detection. You need to define them in +the file jobs/backup-dbfiles.job first. -Remark: -To make a database restore its dump must be located at this directory. +Per database file set a line with the `sqlite = ` prefix -To restore an older database you need to restore the dump from the filke backup first. - -If you have local Mysql daemon or Pgsql you can test it by starting - -``` -# dump all databases -sudo ./localdump.sh +```text +sqlite = /var/lib/whatever/sqlite-database_01.db +sqlite = /var/lib/somewhere/else/db.sqlite ``` -``` -# show written files -find /var/iml-backup -``` +see [backup-dbfiles.job](50_File_backup-dbfiles.job.md) diff --git a/docs/30_Configuration/50_File_backup-dbfiles.job.md b/docs/30_Configuration/50_File_backup-dbfiles.job.md new file mode 100644 index 0000000000000000000000000000000000000000..497c9de1889924cad10ddb68a07ecb01d581fa3c --- /dev/null +++ b/docs/30_Configuration/50_File_backup-dbfiles.job.md @@ -0,0 +1,30 @@ +This is a config file for file based databases that can be anywhere in the filesystem. + +At the moment it is used by sqlite backup only. + +# dist file # + +```text +# ---------------------------------------------------------------------- +# +# jobfile for backup of filebased databases +# list of files with servicename as key ... and its files with full path +# +# ---------------------------------------------------------------------- +# +# SYNTAX: +# [variable] = [value] +# +# - variable must start in first column +# - char "=" must be surrounded by space +# - value - any string; no " needed +# +# EXAMPLE: +# sqlite = /var/lib/whatever/mysqlite-database.db +# +# ---------------------------------------------------------------------- + + + +# ---------------------------------------------------------------------- +``` diff --git a/docs/30_Configuration/50_File_backup.job.md b/docs/30_Configuration/50_File_backup.job.md index 8a0aa2e0c89f893b9a3e400af762e00e1de474d1..79d84f40ef7e51cf077bce6a75fe1331e7a2206d 100644 --- a/docs/30_Configuration/50_File_backup.job.md +++ b/docs/30_Configuration/50_File_backup.job.md @@ -33,12 +33,18 @@ dir-dbarchive = /var/localdumps/archive ## dir-dbarchive ## -Target dir for database archives (to keep deleted schemes or databases that are not backupped anymore; couchdb2 feature) +{string} + +Define the target directory for archived dumps. Do not add a trailing `/`. + +It is used to keep deleted schemes or databases that are not backupped anymore. It is used for couchdb2 only. `dir-dbarchive = /var/localdumps/archive` ## dir-localdumps ## +{string} + Target dir for database backups of all types. Below that directory a subdir for the database type will be created (i.e. mysql or pgsql). @@ -48,6 +54,8 @@ see also **keep-days** ## keep-days ## +{integer} + How many days to keep database dumps locally in `dir-localdumps = ...` `keep-days = 7` @@ -56,4 +64,6 @@ see also **dir-localdumps** ## lang ## +{integer} + Language of the shell. Do not change to keep documented keywords for date and time. diff --git a/docs/40_Usage/10_Database.md b/docs/40_Usage/10_Database.md new file mode 100644 index 0000000000000000000000000000000000000000..35ced633e166d039d1b44930780291f8228f8dca --- /dev/null +++ b/docs/40_Usage/10_Database.md @@ -0,0 +1,98 @@ +## Make database dumps ## + +To create backup dumps we use `./localdump.sh` + +```text +SYNTAX: +localdump.sh [[operation]] [Name_of_service] [[more services]] +localdump.sh restore [Name_of_service] [file-to-restore] + + operation - one of backup|restore; optional parameter; default is backup + Name_of_service - name of database service + You get a list of all available services without parameter + Use ALL for bulk command + file - filename of db dump to restore + +Known services (see ./plugins/localdump): +couchdb +couchdb2 +ldap +mysql +pgsql +sqlite +```text + +If you have local Mysql daemon or Pgsql you can test it by starting + +```text +# dump all databases +sudo ./localdump.sh ALL +``` + +```text +# show written files +find /var/iml-backup +``` + +The keyword **ALL** loops over all databases. If ever possible all schemes will be detected and dumped. + +To dump schemes of a specific database type add the name of a known service. + +```text +# dump all Mysql databases +sudo ./localdump.sh mysql +``` + +## Structure in the backup folder ## + +In the database dump folder is a subdir per service `/var/iml-backup/[service]`. + +Below the service folder are files named like the database scheme + `__` + timestamp. + +All dumps are gzip compressed. + +At the end of a backup task with localdump.sh older files older than *keep-days* +will be deleted from `/var/iml-backup/[service]`. + +### Backup sqlite ### + +Keep in mind that you need to define sqlite databases in jobs/backup-dbfiles.job first. + +```text +# dump all Sqlite databases +sudo ./localdump.sh sqlite +``` + +This greps "^sqlite = " in jobs/backup-dbfiles.job and squentially dumps each sqlite file. + +In the folder /var/iml-backup/sqlite/ it creates 2 files per database + +* the gzip compressed dump (filename is full path with replacing `/` by `_`) +* a .META file that contains the original full path for restore + +## Restore database dumps ## + +Remark: +To make a database restore its dump must be located at this directory. + +The value keepdays contains number of days how long to keep dumps locally. +If your dump to restore is older than this given range then you need +to restore files of /var/iml-backup first. + +To start a restore you need the backup type. You come into an +interactive mode where you get a file selection and can enter +da (new) database where to import these data. + +```text +# restore with selection +sudo ./localdump.sh restore mysql +``` + +If you additionally add a filename of an existing database file the database +will be restored directly into the original database. + +```text +/opt/imlbackup/client/localdump.sh restore mysql /var/iml-backup/mysql/mydatabase__20220127-2303.sql.gz +``` + +With that mechanism you could build a script for a bulk import.