Skip to content
Snippets Groups Projects
Commit 2f9e9f78 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update docs

parent 78779ad0
Branches
No related tags found
1 merge request!30Update docs
# 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)
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
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
```
......@@ -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.
## 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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment