Synchronize data Script
This script is designed to manage backups for various databases. It supports functionalities like downloading the latest backups, selecting daily/weekly/monthly backups, and restoring databases.
Link
You can find the script under Dev services repo . Follow this Gitlab link
Functions
- print_help() :
- Displays the help message and usage instructions.
- parse_yaml() :
- Parses a YAML file and converts it into bash variables.
- compose_file_exists() :
- Checks if the Docker Compose file exists.
- get_odoo_container_name(), get_db_container_name(), get_odoo_image(), get_odoo_hostname():
- Retrieve various details from the Docker Compose configuration.
- get_db_filename() :
- Fetches the filename of the database backup based on the container name.
- db_supported() :
- Checks if the database is supported for synchronization.
- check_dependencies() :
- Installs necessary packages if they are not already installed.
- set_backup_host() :
- Sets the backup host based on the current hostname or network availability.
- shutdown_odoo(), startup_odoo(), shutdown_db(), startup_db() :
- Control Odoo and database services using Docker Compose.
- db_available_on_bkh() :
- Checks if the database backup is available on the backup host.
- choose_file() :
- Allows the user to select a backup file or selects the latest one if the -y option is used.
- download_file() :
- Downloads the specified type of file (db, fs, ex, eth) from the backup host.
- retrieve() :
- Retrieves the selected files based on the download mode.
- wait_db_up() :
- Waits until the database service is up and running.
- restore_db() :
- Restores the database from the downloaded backup file.
- gauge() :
- Displays a progress bar for the database restoration process.
- alter_db() :
- Alters the database configuration after restoration (e.g., updating URLs, disabling cron jobs).
Usage
synchronize_data.sh [OPTION]
Options
- -y : Get the latest backup.
- -d : Only download the database backup.
- -e : Only download the extra-addons backup.
- -f : Only download the filestore backup.
- -s : Select daily backups.
- -w : Select weekly backups.
- -m : Select monthly backups.
- -x : Enable debug mode.
- -h : Print the help message.
Example Commands
# Download the latest backup ./synchronize_data.sh -y # Download only the database backup ./synchronize_data.sh -d # Enable debug mode and select daily backups ./synchronize_data.sh -x -s # Print help message ./synchronize_data.sh -h
— Nadir Habib 2024/06/05 12:21