Verify that the necessary packages are installed. For Ubuntu, you will need the bridge-utils package.
$ sudo apt-get install bridge-utils
$ ip link show
network: version: 2 renderer: networkd ethernets: pc_interface_name: #replace pc_interface_name with the network interface you noted before dhcp4: no dhcp6: no bridges: br0: interfaces: [pc_interface_name] addresses: [192.168.1.128/24] //You can choose a different address if you want gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8]
This only works with wired network. You have to replace networkd with NetworkManager to have your internet access through wifi back
$ sudo netplan apply
$ ip -br a s
$ sudo systemctl restart network-online.target
$ sudo systemctl restart systemd-networkd
$ virsh list --all
$ virsh domiflist vm_name
$ virsh attach-interface --domain vm_name --type bridge --source br0 --model virtio --config --live
<interface type='bridge'> <mac address='52:54:00:09:39:b6'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/> </interface>
$ virsh start VM_name
$ ip -br a s
$ ip link set dev enp9s0 up
$ ip address add 192.168.1.182/24 dev enp9s0
$ ip address show dev enp9s0
$ ping 192.168.1.182
$ ssh vm_username@192.168.1.182
This guide provides step-by-step instructions for installing Docker on Debian.
Open a terminal and update the package index on your Debian system:
$ sudo apt update
Install the necessary packages to enable APT to use repositories over HTTPS and handle certificates:
$ sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
Download and add Docker's official GPG key to your system:
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add the Docker repository to your APT sources by creating a new file:
$ 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
Update the package index to reflect the newly added Docker repository:
$ sudo apt update
Install Docker on your Debian system:
$ sudo apt install -y docker-ce docker-ce-cli containerd.io
Add your username to the docker group:
$ sudo usermod -aG docker username
You can do that by logging out and logging back in or simply by creating a group named docker in your groups list
$ newgrp docker
Verify that Docker is installed correctly by running a test container:
$ sudo docker run hello-world
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 .
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.
#!/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."
Save the script to a file (e.g., backup_script.sh) and make it executable using the command:
$ chmod +x backup_script.sh
To execute the script, simply run:
$ ./backup_script.sh DATABASE FILESTORE_DIR EXTRA_ADDONS_DIR POSTGRES_CONT BACKUP_DIR
The script will create three backup files in a directory of your choice :
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.
$ sudo mkdir path/to/filestore/filestore/database_name
$ sudo tar -xzf /path/to/<DATABASE>_filestore_<DATETIME>.tar.gz -C /path/to/filestore/directory
$ sudo tar -xzf /path/to/<DATABASE>_extra-addons_<DATETIME>.tar.gz -C /path/to/extra-addons/directory
$ docker exec -i <db_container_name> createdb -U odoo <DATABASE>
Replace <DATABASE> with the database name you want to restore
$ gunzip -c /path/to/<DATABASE>_database_<DATETIME>.sql.bz2 | docker exec -i <db_container_name> psql -U odoo --dbname=<DATABASE>
- 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.
#!/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."
$ chmod +x restore_script.sh
$ ./restore_script.sh DATABASE FILESTORE_DIR EXTRA_ADDONS_DIR POSTGRES_CONT BACKUP_DIR
$ ./restore_script.sh my_odoo_db /path/to/odoo/filestore /path/to/odoo/extra-addons odoo_postgres_container /path/to/backup/destination