Description

To create backup database dumps without transfer of local directory to a backup target use sudo ./localdump.sh. Backup dumps will be stored as gzip files into /var/iml-backup/[profile].

Help

LOCALDUMP detects existing local databases and dumps them locally.
It is included in the backup.sh to dump all before a file backup will store 
them. It can be started seperately for manual database backups or for restore.

SYNTAX:
    localdump.sh [OPTIONS] <operation> <profile [more_profiles]>

OPTIONS:
    -h|--help   show this help

PARAMETERS:"
    operation   - one of check|backup|restore; optional parameter
                      backup   dump all databases/ schemes of a given service
                      check    show info only if the service is available
                      restore  import a dump into same or new database
                               Without a filename it starts an interactive mode
    profile     - name of database profiles
                  You get a list of all available services without parameter
                  Use ALL for bulk command
    file        - filename of db dump to restore to origin database scheme

EXAMPLES:
    localdump.sh backup
    localdump.sh backup ALL
                 Backup all databases of all found services
    localdump.sh backup mysql
                 Backup all Mysql databases.

    localdump.sh restore
                 Start interactive restore of a database of any service.
    localdump.sh restore sqlite
                 Start interactive restore of an sqlite database.
    localdump.sh restore <file-to-restore> [<database-name>]
                 Restore a given dump file to the origin database scheme or
                 to a new/ other database with the given name.

If you have local Mysql daemon or Pgsql you can test it by starting

# dump all databases
sudo ./localdump.sh backup ALL
# 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.

# dump all Mysql databases
sudo ./localdump.sh backup mysql

Structure in the backup folder

In the database dump folder is a subdir per service /var/iml-backup/[profile].

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 create an ini file to enable sqlite backups. See plogins/localdump/profiles/sqlite.ini.example.

# dump all Sqlite databases
sudo ./localdump.sh sqlite

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: /var/iml-backup/[service]

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.

# 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.

/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.