This is an old revision of the document!


How to Create a Bridge Connection Between PC and VM

Verify that the necessary packages are installed. For Ubuntu, you will need the bridge-utils package.

$ sudo apt-get install bridge-utils 
  • 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.):
$ ip link show
  • 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:
  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]

!!Note!!

This only works with wired network. You have to replace networkd with NetworkManager to have your internet access through wifi back

  • Apply the network configuration:
$ sudo netplan apply
  • This will create the bridge interface (br0) and associate it with the physical interface you can check that using:
$ ip -br a s
  • If not you can restart your network:
$ sudo systemctl restart network-online.target
  • Or:
$ sudo systemctl restart systemd-networkd
  • Make sure the vm is shut off before applying any changes , check using the following command:
$ virsh list --all
  • 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:
$ virsh domiflist vm_name
  • Connect the VM to the bridge interface:
$ virsh attach-interface --domain vm_name --type bridge --source br0 --model virtio --config --live
  • 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>:
    <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>
  • Save the changes and exit
  • Launch the VM using:
$ virsh start VM_name
  • On the VM Terminal check the network interfaces names using :
$ ip -br a s
  • You will notice that there is an additional interface named (e.g: enp9s0) if it's DOWN use this command to set it UP:
$ ip link set dev enp9s0 up
  • Replace enp9s0 according to your interface name
  • Add an ip address of your choice:
$ ip address add 192.168.1.182/24 dev enp9s0
  • Replace enp9s0 according to your interface name
  • Check if it's running using :
$ ip address show dev enp9s0
  • Verify connectivity by accessing the VM from the PC:
$ ping 192.168.1.182 
  • Or:
$ ssh vm_username@192.168.1.182
  • Change the address according to your configuration

Docker Installation Guide for Debian

This guide provides step-by-step instructions for installing Docker on Debian.

  • A Debian-based system
  • Administrative privileges (sudo access)

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

Documentation: 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 .

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.

Before running the script, you need to make some adjustments:

  • 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.
#!/bin/bash

# Prompt user for database name
read -p "Enter the name of the Odoo database: " DATABASE

# Prompt user for filestore directory path
read -p "Enter the path to the Odoo filestore directory: " FILESTORE_DIR

# Prompt user for extra-addons directory path
read -p "Enter the path to the Odoo extra-addons directory: " EXTRA_ADDONS_DIR

# Prompt user for postgres container name
read -p "Enter the path to the postgres container name " POSTGRES_CONT

# Prompt user for the backup destination directory
read -p "Enter the path to the backup destination directory: " BACKUP_DIR

# 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

# Perform the Filestore Backup
tar -C "$FILESTORE_DIR" -czf "$BACKUP_DIR/$FILESTORE_ARCHIVE" .

# Perform the Extra Addons Backup
tar -C "$EXTRA_ADDONS_DIR" -czf "$BACKUP_DIR/$EXTRA_ADDONS_ARCHIVE" .

# Perform the Database Backup
docker exec -i "$POSTGRES_CONT" pg_dump -U odoo --create --format=plain "$DATABASE" | gzip > "$BACKUP_DIR/$DATABASE_ARCHIVE"

echo "Backups completed successfully and stored in $BACKUP_DIR"

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

The script will create three backup files in the current directory:

  • <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.

  • 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
$ sudo mkdir path/to/filestore/filestore/database_name
  • Decompress and restore the filestore backup on the VM using the following command:
$ tar -xzf /path/to/<DATABASE>_filestore_<DATETIME>.tar.gz -C /path/to/filestore/directory
  • 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:
$ tar -xzf /path/to/<DATABASE>_extra-addons_<DATETIME>.tar.gz -C /path/to/extra-addons/directory
  • 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 :
$ docker exec -i odoo15_db createdb -U odoo <DATABASE>

Replace <DATABASE> with the database name you want to restore

  • Decompress and restore the database backup on the VM using the following command:
$ gunzip -c /path/to/<DATABASE>_database_<DATETIME>.sql.bz2 | docker exec -i odoo15_db psql -U odoo --dbname=<DATABASE>
  • 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.

  • user/nadir.1690461233.txt.gz
  • Last modified: 2023/07/27 13:33
  • by nadir