elosys:windows_backup

Windows Backup Script

  • This script automates the process of creating backups for an Odoo instance's extra-addons directory, filestore, and PostgreSQL database . It compresses the backups and saves them in a designated backup directory.
  • You can find the script on Gitlab
  • The script begins by loading configurations from the wrestore.conf file. This file contains key-value pairs in the format key=value, providing necessary configurations for the backup process. Configurations include:
    • PG_PASSWORD: PostgreSQL password.
    • BACKUP_DIR: Directory path where backups will be stored.
    • ODOO_DIR: Directory path where the Odoo instance is installed.
    • PG_BIN: Path to the directory containing PostgreSQL binaries.
    • PG_USER: PostgreSQL user.
    • PG_DBNAME: Name of the PostgreSQL database.
    • FILESTORE_DIR: Directory path where the filestore backup is stored.
    • WINRAR_PATH: Path to the WinRAR executable.
  • The script displays the loaded configurations for debugging purposes, confirming the configurations loaded from the wrestore.conf file.
  • The script retrieves the current date and time in the format yyyy-mm-dd_HH-MM using wmic os get localdatetime. This timestamp is used to uniquely identify each backup.
  • The script constructs the file names for the backup files based on the current timestamp. It sets variables for the names of the backup files for extra-addons, filestore, and database.
  • The script checks if WinRAR is installed at the specified path. If WinRAR is not found, the script exits with an error code.
  • The script creates a backup of the extra-addons directory of the Odoo instance using WinRAR. It compresses the contents of the directory and saves them as a ZIP file in the designated backup directory.
  • The script creates a backup of the filestore directory using WinRAR. It compresses the contents of the directory and saves them as a ZIP file in the designated backup directory.
  • The script creates a backup of the PostgreSQL database using the pg_dump utility. It dumps the database schema and data into a custom-format file and saves it in the designated backup directory.
  • The script compresses the database backup file from the previous step using WinRAR. It saves the compressed file in the same directory with the extension .bz2.
  • The script deletes the uncompressed SQL file after compression to save disk space.
  • Finally, the script indicates the completion of the backup process.

— Nadir Habib 2024/04/26 19:10

  • elosys/windows_backup.txt
  • Last modified: 2024/04/26 19:12
  • by nadir