Differences

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

Link to this comparison view

Next revision
Previous revision
user:nadir [2023/06/02 21:54] nadiruser:nadir [2023/12/27 11:35] (current) nadir
Line 3: Line 3:
 ===== Prerequisites ===== ===== Prerequisites =====
 Verify that the necessary packages are installed. For Ubuntu, you will need the bridge-utils package. Verify that the necessary packages are installed. For Ubuntu, you will need the bridge-utils package.
-<konsole+<cli
-#-$ sudo apt-get install bridge-utils  +$ sudo apt-get install bridge-utils  
-</konsole>+</cli>
  
 ===== Step 1 ===== ===== Step 1 =====
  
   * Identify the physical network interface of the PC using the following command and note down the name of the physical interface (e.g., eth0, enp1s0, etc.):   * Identify the physical network interface of the PC using the following command and note down the name of the physical interface (e.g., eth0, enp1s0, etc.):
- <konsole+ <cli
- #-$ ip link show +$ ip link show 
-</konsole>+</cli>
  
 ===== Step 2 ===== ===== Step 2 =====
Line 20: Line 20:
   * Open the network configuration file using a text editor at "/etc/netplan/" (Ubuntu)   * Open the network configuration file using a text editor at "/etc/netplan/" (Ubuntu)
   * Create a new configuration file (e.g., bridge.yaml) or modify an existing one and paste the following configuration:   * Create a new configuration file (e.g., bridge.yaml) or modify an existing one and paste the following configuration:
-  <konsole>+  <code>
   network:   network:
     version: 2     version: 2
Line 35: Line 35:
       nameservers:       nameservers:
         addresses: [8.8.8.8]         addresses: [8.8.8.8]
-</konsole>+</code>
  
 === !!Note!! === === !!Note!! ===
Line 42: Line 42:
  
   * Apply the network configuration:   * Apply the network configuration:
-    <konsole+<cli
-#-$ sudo netplan apply +$ sudo netplan apply 
-</konsole>+</cli>
  
       * This will create the bridge interface (br0) and associate it with the physical interface you can check that using:       * This will create the bridge interface (br0) and associate it with the physical interface you can check that using:
-    <konsole+<cli
-#-$ ip -br a s +$ ip -br a s 
-</konsole>+</cli>
  
       * If not you can restart your network:       * If not you can restart your network:
-    <konsole+<cli
-#-$ sudo systemctl restart network-online.target +$ sudo systemctl restart network-online.target 
-</konsole>+</cli>
  
       Or:       Or:
          
-<konsole+<cli
-#-$ sudo systemctl restart systemd-networkd +$ sudo systemctl restart systemd-networkd 
-</konsole>+</cli>
  
 ===== Step 3 ===== ===== Step 3 =====
Line 68: Line 68:
   * Make sure the vm is shut off before applying any changes , check using the following command:   * Make sure the vm is shut off before applying any changes , check using the following command:
  
-<konsole+<cli
-#-$ virsh list --all +$ virsh list --all 
-</konsole>+</cli>
  
   * Modify the XML configuration file of the VM to use the bridge interface (br0) instead of a virtual network you can do that usig the following commands or manually which i'll be mentioning it afterwards:   * Modify the XML configuration file of the VM to use the bridge interface (br0) instead of a virtual network you can do that usig the following commands or manually which i'll be mentioning it afterwards:
      * Determine the name of the VM's network interface: Run the following command on the host machine to list  the available network interfaces of the VM:      * Determine the name of the VM's network interface: Run the following command on the host machine to list  the available network interfaces of the VM:
  
-<konsole+<cli
-#-$ virsh domiflist <vm_name> +$ virsh domiflist vm_name 
-</konsole>+</cli>
  
      * Connect the VM to the bridge interface:      * Connect the VM to the bridge interface:
    
-<konsole+<cli
-#-$ virsh attach-interface --domain vm_name --type bridge --source br0 --model virtio --config --live +$ virsh attach-interface --domain vm_name --type bridge --source br0 --model virtio --config --live 
-</konsole>+</cli>
  
 ==== Manually ==== ==== Manually ====
Line 89: Line 89:
   * Locate the XML configuration file of the VM (e.g., /etc/libvirt/qemu/<vm_name>.xml)and open it with a text editor of your choice   * Locate the XML configuration file of the VM (e.g., /etc/libvirt/qemu/<vm_name>.xml)and open it with a text editor of your choice
   * Locate the tag <interface> and add the follwing after the closing tag of interface </interface>:   * Locate the tag <interface> and add the follwing after the closing tag of interface </interface>:
-<konsole>+<code>
     <interface type='bridge'>     <interface type='bridge'>
         <mac address='52:54:00:09:39:b6'/>         <mac address='52:54:00:09:39:b6'/>
Line 96: Line 96:
         <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>         <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
     </interface>     </interface>
-</konsole>+</code>
  
   * Save the changes and exit   * Save the changes and exit
Line 105: Line 105:
  
   * Launch the VM using:   * Launch the VM using:
-<konsole+<cli
-#-$ virsh start VM_name +$ virsh start VM_name 
-</konsole>+</cli>
   * On the VM Terminal check the network interfaces names using :   * On the VM Terminal check the network interfaces names using :
-<konsole+<cli
- #-$ ip -br a s +$ ip -br a s 
-</konsole>+</cli>
   * You will notice that there is an additional interface named (e.g: enp9s0) if it's DOWN use this command to set it UP:   * You will notice that there is an additional interface named (e.g: enp9s0) if it's DOWN use this command to set it UP:
-<konsole+<cli
-#-$ ip link set dev enp9s0 up +$ ip link set dev enp9s0 up 
-</konsole+</cli
-    * Replace enp9s0 according to your interface name+  * Replace enp9s0 according to your interface name
   * Add an ip address of your choice:   * Add an ip address of your choice:
-<konsole+<cli
-#-$ ip address add 192.168.1.182/24 dev enp9s0 +$ ip address add 192.168.1.182/24 dev enp9s0 
-</konsole>  +</cli>  
-    * Replace enp9s0 according to your interface name+  * Replace enp9s0 according to your interface name
   * Check if it's running using :   * Check if it's running using :
-<konsole+<cli
-#-$ ip address show dev enp9s0 +$ ip address show dev enp9s0 
-</konsole>+</cli>
  
   * Verify connectivity by accessing the VM from the PC:   * Verify connectivity by accessing the VM from the PC:
  
- <konsole+ <cli
- #-$ ping 192.168.1.182 //# change the address acording to your configuration// +$ ping 192.168.1.182  
-</konsole>+</cli>
  
   * Or:   * Or:
    
-<konsole+<cli
-#-$ ssh vm_username@192.168.1.182 +$ ssh vm_username@192.168.1.182 
-</konsole>+</cli>
  
   * Change the address according to your configuration   * Change the address according to your configuration
  
  
 +====== Docker Installation Guide for Debian ======
  
 +This guide provides step-by-step instructions for installing Docker on Debian.
  
 +=== Prerequisites ===
  
 +  * A Debian-based system
 +  * Administrative privileges (sudo access)
  
 +=== Step 1: Update Package Index ===
 +
 +Open a terminal and update the package index on your Debian system:
 +
 +<cli>
 +$ sudo apt update
 +</cli>
 +
 +=== Step 2: Install Dependencies ===
 +
 +Install the necessary packages to enable APT to use repositories over HTTPS and handle certificates:
 +
 +<cli>
 +$ sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
 +</cli>
 +
 +=== Step 3: Add Docker's Official GPG Key ===
 +
 +Download and add Docker's official GPG key to your system:
 +
 +<cli>
 +$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
 +</cli>
 +
 +=== Step 4: Add Docker Repository ===
 +
 +Add the Docker repository to your APT sources by creating a new file:
 +
 +<cli>
 +$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
 +
 +</cli>
 +
 +=== Step 5: Update Package Index Again ===
 +
 +Update the package index to reflect the newly added Docker repository:
 +
 +<cli>
 +$ sudo apt update
 +</cli>
 +
 +=== Step 6: Install Docker ===
 +
 +Install Docker on your Debian system:
 +
 +<cli>
 +$ sudo apt install -y docker-ce docker-ce-cli containerd.io
 +</cli>
 +
 +=== Step 7: Add user to the docker group ===
 +
 +Add your username to the docker group:
 +
 +<cli>
 +$ sudo usermod -aG docker username
 +</cli>
 +
 +=== 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
 +
 +<cli>
 +$ newgrp docker
 +</cli>
 +
 +=== Step 9: Verify Docker Installation ===
 +
 +Verify that Docker is installed correctly by running a test container:
 +
 +<cli>
 +$ sudo docker run hello-world
 +</cli>
 +
 +
 +
 +====== Backup Script for Proxmox VM ======
 +
 +
 +This documentation will guide you through using the provided backup script to create backups for a virtual machine (VM) running on Proxmox. The script will create backup files for the Odoo filestore, database, and extra-addons .
 +
 +===== 1. Script Overview =====
 +
 +The backup script is designed to create separate backup files for the Odoo filestore, database, and extra-addons. Each backup file will be named with the current date and time (YYYY-MM-DD_HH-MM-SS) to ensure uniqueness.
 +
 +
 +===== 2. Running the Backup Script =====
 +
 +<cli>
 +
 +
 +#!/bin/bash
 +
 +# Usage function
 +usage() {
 +    echo "Usage: $0 DATABASE FILESTORE_DIR EXTRA_ADDONS_DIR POSTGRES_CONT BACKUP_DIR"
 +    echo "       DATABASE: Name of the Odoo database to backup"
 +    echo "       FILESTORE_DIR: Path to the Odoo filestore directory"
 +    echo "       EXTRA_ADDONS_DIR: Path to the Odoo extra-addons directory"
 +    echo "       POSTGRES_CONT: Name of the PostgreSQL container"
 +    echo "       BACKUP_DIR: Path to the backup destination directory"
 +}
 +
 +# 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>
 +
 +
 +Save the script to a file (e.g., backup_script.sh) and make it executable using the command:
 +
 +<cli>
 +$ chmod +x backup_script.sh
 +</cli>
 +
 +To execute the script, simply run:
 +
 +<cli>
 +$ ./backup_script.sh DATABASE FILESTORE_DIR EXTRA_ADDONS_DIR POSTGRES_CONT BACKUP_DIR
 +</cli>
 +
 +  * 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 a directory of your choice :
 +
 +  * <DATABASE>_filestore_<DATETIME>.tar.gz: Backup for the Odoo filestore.
 +  * <DATABASE>_database_<DATETIME>.sql.bz2: Backup for the Odoo database.
 +  * <DATABASE>_extra-addons_<DATETIME>.tar.gz: Backup for the Odoo extra-addons.
 +
 +====== Restoring the Backups ======
 +
 +In the event of data loss or VM issues, you can use these backup files to restore the Odoo VM. Ensure you have backups available for all three components: filestore, database, and extra-addons.
 +
 +===== Step 1: Restore the Filestore =====
 +
 +  * SSH into your Proxmox server as the appropriate user with privileges to manage VMs.
 +  * Upload the filestore backup (<DATABASE>_filestore_<DATETIME>.tar.gz) to the appropriate directory on the VM. You can use scp or any other file transfer method to upload the file.
 +  * Create a file in the filestore/filestore named with the database name 
 +<cli>
 +$ sudo mkdir path/to/filestore/filestore/database_name
 +</cli>
 +  * Decompress and restore the filestore backup on the VM using the following command:
 +<cli>
 +$ sudo tar -xzf /path/to/<DATABASE>_filestore_<DATETIME>.tar.gz -C /path/to/filestore/directory
 +</cli>
 +
 +===== Step 2: Restore the Extra Addons =====
 +
 +  * Upload the extra-addons backup (<DATABASE>_extra-addons_<DATETIME>.tar.gz) to the appropriate directory on the VM.
 +  * Decompress and restore the extra-addons backup on the VM using the following command:
 +<cli>
 +$ sudo tar -xzf /path/to/<DATABASE>_extra-addons_<DATETIME>.tar.gz -C /path/to/extra-addons/directory
 +</cli>
 +
 +===== Step 3: Restore the Database =====
 +
 +  * 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:
 +
 +<cli>
 +$ gunzip -c /path/to/<DATABASE>_database_<DATETIME>.sql.bz2 | docker exec -i <db_container_name> psql -U odoo --dbname=<DATABASE>
 +</cli>
 +
 +  * Replace <DATABASE> with the name of the Odoo database you want to restore.
 +
 +====== Odoo Backup Restoration Script ======
 +
 +- 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>
 +#!/bin/bash
 +
 +# 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.1685739274.txt.gz
  • Last modified: 2023/06/02 21:54
  • by nadir