Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
user:nadir [2023/07/27 10:48] nadiruser:nadir [2023/12/27 11:35] (current) nadir
Line 146: Line 146:
 This guide provides step-by-step instructions for installing Docker on Debian. This guide provides step-by-step instructions for installing Docker on Debian.
  
-===== Prerequisites =====+=== Prerequisites ===
  
   * A Debian-based system   * A Debian-based system
   * Administrative privileges (sudo access)   * Administrative privileges (sudo access)
  
-===== Step 1: Update Package Index =====+=== Step 1: Update Package Index ===
  
 Open a terminal and update the package index on your Debian system: Open a terminal and update the package index on your Debian system:
Line 159: Line 159:
 </cli> </cli>
  
-===== Step 2: Install Dependencies =====+=== Step 2: Install Dependencies ===
  
 Install the necessary packages to enable APT to use repositories over HTTPS and handle certificates: Install the necessary packages to enable APT to use repositories over HTTPS and handle certificates:
Line 167: Line 167:
 </cli> </cli>
  
-===== Step 3: Add Docker's Official GPG Key =====+=== Step 3: Add Docker's Official GPG Key ===
  
 Download and add Docker's official GPG key to your system: Download and add Docker's official GPG key to your system:
Line 175: Line 175:
 </cli> </cli>
  
-===== Step 4: Add Docker Repository =====+=== Step 4: Add Docker Repository ===
  
 Add the Docker repository to your APT sources by creating a new file: Add the Docker repository to your APT sources by creating a new file:
Line 184: Line 184:
 </cli> </cli>
  
-===== Step 5: Update Package Index Again =====+=== Step 5: Update Package Index Again ===
  
 Update the package index to reflect the newly added Docker repository: Update the package index to reflect the newly added Docker repository:
Line 192: Line 192:
 </cli> </cli>
  
-===== Step 6: Install Docker =====+=== Step 6: Install Docker ===
  
 Install Docker on your Debian system: Install Docker on your Debian system:
Line 200: Line 200:
 </cli> </cli>
  
-===== Step 7: Add user to the docker group =====+=== Step 7: Add user to the docker group ===
  
 Add your username to the docker group: Add your username to the docker group:
Line 208: Line 208:
 </cli> </cli>
  
-===== Step 8: Add docker to user groups =====+=== Step 8: Add docker to user groups ===
    
 You can do that by logging out and logging back in or simply by creating a group named docker in your groups list You can do that by logging out and logging back in or simply by creating a group named docker in your groups list
Line 216: Line 216:
 </cli> </cli>
  
-===== Step 9: Verify Docker Installation =====+=== Step 9: Verify Docker Installation ===
  
 Verify that Docker is installed correctly by running a test container: Verify that Docker is installed correctly by running a test container:
Line 226: Line 226:
  
  
-====== Documentation: Backup Script for Proxmox VM ======+====== Backup Script for Proxmox VM ======
  
  
Line 236: Line 236:
  
  
-===== 2. Script Configuration =====+===== 2. Running the Backup Script =====
  
-Before running the script, you need to make some adjustments:+<cli>
  
-  * Replace 'Database' with the name of the Odoo database you want to back up. 
-  * Update /Path/to/filestore/filestore/Database to the correct path of your Odoo filestore directory. 
-  * Update /path/to/extra-addons to the correct path of your Odoo extra-addons directory. 
  
-===== 3. Running the Backup Script =====+#!/bin/bash
  
-<code> +# Usage function 
-DATETIME=`date +\%Y-\%m-\%d_\%H-\%M-\%S` && \ +usage() { 
-DATABASE='Database' && \ +    echo "Usage: $0 DATABASE FILESTORE_DIR EXTRA_ADDONS_DIR POSTGRES_CONT BACKUP_DIR" 
-FILESTORE_ARCHIVE="$DATABASE"_filestore_"$DATETIME".tar.gz && \ +    echo "       DATABASE: Name of the Odoo database to backup" 
-DATABASE_ARCHIVE="$DATABASE"_database_"$DATETIME".sql.bz2 && \ +    echo "       FILESTORE_DIR: Path to the Odoo filestore directory" 
-EXTRA_ADDONS_ARCHIVE="$DATABASE"_extra-addons_"$DATETIME".tar.gz && +    echo "       EXTRA_ADDONS_DIR: Path to the Odoo extra-addons directory" 
-tar -C /Path/to/filestore/filestore/ssd_test -c . | gzip -n > ./$FILESTORE_ARCHIVE && \ +    echo "       POSTGRES_CONT: Name of the PostgreSQL container" 
-tar -C /Path/to/extra-addons -c . | gzip -n > ./$EXTRA_ADDONS_ARCHIVE && \ +    echo "       BACKUP_DIR: Path to the backup destination directory" 
-docker exec -i odoo15_db pg_dump -U odoo --create --format=plain $DATABASE | gzip > ./$DATABASE_ARCHIVE +
-</code>+ 
 +# Check the number of arguments 
 +if [ $# -ne 5 ]; then 
 +    usage 
 +    exit 1 
 +fi 
 + 
 +# Assign command-line arguments to variables 
 +DATABASE=$1 
 +FILESTORE_DIR=$2 
 +EXTRA_ADDONS_DIR=$3 
 +POSTGRES_CONT=$4 
 +BACKUP_DIR=$5 
 + 
 +# Generate the backup date and time 
 +DATETIME=$(date +\%Y-\%m-\%d_\%H-\%M-\%S) 
 + 
 +# Backup filenames 
 +FILESTORE_ARCHIVE="$DATABASE"_filestore_"$DATETIME".tar.gz 
 +DATABASE_ARCHIVE="$DATABASE"_database_"$DATETIME".sql.bz2 
 +EXTRA_ADDONS_ARCHIVE="$DATABASE"_extra-addons_"$DATETIME".tar.gz 
 + 
 +# Function to log messages to the terminal 
 +log_message() { 
 +    echo "$(date +\%Y-\%m-\%d_\%H:\%M:\%S): $1" 
 +
 + 
 +# Start logging 
 +log_message "Backup process started." 
 + 
 +# Perform the Filestore Backup 
 +log_message "Performing Filestore Backup..." 
 +tar -C "$FILESTORE_DIR" -czf "$BACKUP_DIR/$FILESTORE_ARCHIVE" . 2>&1 | log_message 
 +log_message "Filestore Backup completed." 
 + 
 +# Perform the Extra Addons Backup 
 +log_message "Performing Extra Addons Backup..." 
 +tar -C "$EXTRA_ADDONS_DIR" -czf "$BACKUP_DIR/$EXTRA_ADDONS_ARCHIVE" . 2>&1 | log_message 
 +log_message "Extra Addons Backup completed." 
 + 
 +# Perform the Database Backup 
 +log_message "Performing Database Backup..." 
 +docker exec -i "$POSTGRES_CONT" pg_dump -U odoo --create --format=plain "$DATABASE| gzip > "$BACKUP_DIR/$DATABASE_ARCHIVE" 2>&1 | log_message 
 +log_message "Database Backup completed." 
 + 
 +# End logging 
 +log_message "Backup process completed." 
 + 
 +# Print message to the terminal 
 +echo "Backups completed successfully." 
 +</cli>
  
  
Line 267: Line 314:
  
 <cli> <cli>
-$ ./backup_script.sh+$ ./backup_script.sh DATABASE FILESTORE_DIR EXTRA_ADDONS_DIR POSTGRES_CONT BACKUP_DIR
 </cli> </cli>
  
-The script will create three backup files in the current directory:+  * DATABASE: Name of the Odoo database to backup. 
 +  * FILESTORE_DIR: Path to the Odoo filestore directory. 
 +  * EXTRA_ADDONS_DIR: Path to the Odoo extra-addons directory. 
 +  * POSTGRES_CONT: Name of the PostgreSQL container associated with Odoo. 
 +  * BACKUP_DIR: Path to the backup destination directory. 
 + 
 + 
 +The script will create three backup files in directory of your choice :
  
   * <DATABASE>_filestore_<DATETIME>.tar.gz: Backup for the Odoo filestore.   * <DATABASE>_filestore_<DATETIME>.tar.gz: Backup for the Odoo filestore.
Line 290: Line 344:
   * Decompress and restore the filestore backup on the VM using the following command:   * Decompress and restore the filestore backup on the VM using the following command:
 <cli> <cli>
-$ tar -xzf /path/to/<DATABASE>_filestore_<DATETIME>.tar.gz -C /path/to/filestore/directory+sudo tar -xzf /path/to/<DATABASE>_filestore_<DATETIME>.tar.gz -C /path/to/filestore/directory
 </cli> </cli>
  
Line 298: Line 352:
   * Decompress and restore the extra-addons backup on the VM using the following command:   * Decompress and restore the extra-addons backup on the VM using the following command:
 <cli> <cli>
-$ tar -xzf /path/to/<DATABASE>_extra-addons_<DATETIME>.tar.gz -C /path/to/extra-addons/directory+sudo tar -xzf /path/to/<DATABASE>_extra-addons_<DATETIME>.tar.gz -C /path/to/extra-addons/directory
 </cli> </cli>
  
Line 304: Line 358:
  
   * Upload the database backup (<DATABASE>_database_<DATETIME>.sql.bz2) to the VM.   * Upload the database backup (<DATABASE>_database_<DATETIME>.sql.bz2) to the VM.
 +  * If the database was completly deleted you need to create the database first by running this command :
 +
 +<cli>
 +$ docker exec -i <db_container_name> createdb -U odoo <DATABASE>
 +</cli>
 +
 +Replace <DATABASE> with the database name you want to restore
 +
   * Decompress and restore the database backup on the VM using the following command:   * Decompress and restore the database backup on the VM using the following command:
  
 <cli> <cli>
-$ gunzip -c /path/to/<DATABASE>_database_<DATETIME>.sql.bz2 | docker exec -i odoo15_db psql -U odoo --dbname=<DATABASE>+$ gunzip -c /path/to/<DATABASE>_database_<DATETIME>.sql.bz2 | docker exec -i <db_container_name> psql -U odoo --dbname=<DATABASE>
 </cli> </cli>
  
   * Replace <DATABASE> with the name of the Odoo database you want to restore.   * Replace <DATABASE> with the name of the Odoo database you want to restore.
  
-Please note that this documentation assumes you are using a Docker container named odoo15_db for the Odoo database. Modify the docker exec command to match your specific Odoo setup.+====== Odoo Backup Restoration Script ======
  
-If the database was completly deleted you need to create the database first by running this command :+- This bash script is designed to automate the process of restoring backups for Odoo in case of data loss or VM issues. The script restores the filestore, extra-addons, and database backups, allowing you to recover your Odoo VM efficiently.
  
 +
 +===== Prerequisites =====
 +
 +  * Ensure that Docker is installed on the system and the necessary permissions are set to execute Docker commands.
 +  * You should have access to the Odoo PostgreSQL container and the required Odoo directories (filestore and extra-addons).
 +  * Make sure you have the necessary backup files available for the filestore, extra-addons, and database components.
 +
 +===== Usage =====
 <cli> <cli>
-$ docker exec -i odoo15_db createdb -U odoo Database +#!/bin/bash
-</cli>+
  
-Replace database with the database name you want to restore+# Function to print log messages 
 +log_message() { 
 +    echo "$(date +\%Y-\%m-\%d_\%H:\%M:\%S): $1" 
 +}
  
 +# Function to decompress and restore filestore backup
 +restore_filestore() {
 +    log_message "Restoring the Filestore..."
 +    sudo mkdir -p "$FILESTORE_DIR/$DATABASE"
 +    sudo tar -xzf "$BACKUP_DIR/$FILESTORE_ARCHIVE" -C "$FILESTORE_DIR/$DATABASE"
 +    log_message "Filestore Restore completed."
 +}
  
 +# Function to decompress and restore extra-addons backup
 +restore_extra_addons() {
 +    log_message "Restoring the Extra Addons..."
 +    sudo tar -xzf "$BACKUP_DIR/$EXTRA_ADDONS_ARCHIVE" -C "$EXTRA_ADDONS_DIR"
 +    log_message "Extra Addons Restore completed."
 +}
  
 +# Function to restore the database
 +restore_database() {
 +    log_message "Restoring the Database..."
 +    docker exec -i "$POSTGRES_CONT" createdb -U odoo "$DATABASE"
 +    gunzip -c "$BACKUP_DIR/$DATABASE_ARCHIVE" | docker exec -i "$POSTGRES_CONT" psql -U odoo --dbname="$DATABASE"
 +    log_message "Database Restore completed."
 +}
  
 +# Check the number of arguments
 +if [ $# -ne 5 ]; then
 +    echo "Usage: $0 DATABASE FILESTORE_DIR EXTRA_ADDONS_DIR POSTGRES_CONT BACKUP_DIR"
 +    exit 1
 +fi
  
 +# Assign command-line arguments to variables
 +DATABASE=$1
 +FILESTORE_DIR=$2
 +EXTRA_ADDONS_DIR=$3
 +POSTGRES_CONT=$4
 +BACKUP_DIR=$5
  
 +# Backup filenames
 +FILESTORE_ARCHIVE="$DATABASE"_filestore_"$DATETIME".tar.gz
 +DATABASE_ARCHIVE="$DATABASE"_database_"$DATETIME".sql.bz2
 +EXTRA_ADDONS_ARCHIVE="$DATABASE"_extra-addons_"$DATETIME".tar.gz
 +
 +# Backup date and time
 +DATETIME=$(date +\%Y-\%m-\%d_\%H-\%M-\%S)
 +
 +# Start restoring the backups
 +log_message "Restoration process started."
 +
 +# Step 1: Restore the Filestore
 +restore_filestore
 +
 +# Step 2: Restore the Extra Addons
 +restore_extra_addons
 +
 +# Step 3: Restore the Database
 +restore_database
 +
 +# End restoration
 +log_message "Restoration process completed."
 +
 +# Print message to the terminal
 +echo "Restoration completed successfully."
 +
 +</cli>
 +
 +  * Save the script in a file named restore_script.sh.
 +  * Make the script executable with the following command:
 +<cli>
 +$ chmod +x restore_script.sh
 +</cli>
 +
 +  * Execute the script with the required arguments:
 +
 +<cli>
 +$ ./restore_script.sh DATABASE FILESTORE_DIR EXTRA_ADDONS_DIR POSTGRES_CONT BACKUP_DIR
 +</cli>
 +
 +  * DATABASE: Name of the Odoo database to restore.
 +  * FILESTORE_DIR: Path to the Odoo filestore directory.
 +  * EXTRA_ADDONS_DIR: Path to the Odoo extra-addons directory.
 +  * POSTGRES_CONT: Name of the PostgreSQL container associated with Odoo.
 +  * BACKUP_DIR: Path to the directory containing the backup files.
 +
 +===== Example =====
 +
 +<cli>
 +$ ./restore_script.sh my_odoo_db /path/to/odoo/filestore /path/to/odoo/extra-addons odoo_postgres_container /path/to/backup/destination
 +</cli>
  
 +===== Restoration Process =====
  
 +  * The script performs the following restoration steps:
 +  * Restores the filestore backup to the specified filestore directory.
 +  * Restores the extra-addons backup to the specified extra-addons directory.
 +  * Creates the Odoo database (if it was completely deleted) and restores the database backup.
  
 +[[http://babyshop-dz.com]]
    
  
  • user/nadir.1690451302.txt.gz
  • Last modified: 2023/07/27 10:48
  • by nadir