====== 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. ==== Link ==== * You can find the script on [[https://git.elosys.net/sys/wrestore/-/blob/feature_bug_fixes/wbackup.bat?ref_type=heads|Gitlab]] ==== 1. Configuration Loading ==== * 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. ==== 2. Displaying Loaded Configurations ==== * The script displays the loaded configurations for debugging purposes, confirming the configurations loaded from the wrestore.conf file. ==== 3. Generating Timestamp ==== * 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. ==== 4. Paths for Backup Files ==== * 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**. ==== 5. Checking WinRAR Installation ==== * The script checks if **WinRAR** is installed at the specified path. If **WinRAR** is not found, the script exits with an error code. ==== 6. Backup Extra-Addons Directory ==== * 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. ==== 7. Backup Filestore 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. ==== 8. Backup Database ==== * 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. ==== 9. Compressing Database Backup ==== * 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**. ==== 10. Cleanup ==== * The script deletes the uncompressed **SQL** file after compression to save disk space. ==== 11. Completion ==== * Finally, the script indicates the completion of the backup process. ---- --- //[[nadirhabib96@gmail.com|Nadir Habib]] 2024/04/26 19:10//