Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| user:nadir [2023/07/27 09:59] – nadir | user:nadir [2025/08/10 13:32] (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 "/ | * Open the network configuration file using a text editor at "/ | ||
| * 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: | ||
| - | | + | <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: | ||
| - | | + | <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: | ||
| - | | + | <cli> |
| - | #-$ sudo systemctl restart network-online.target | + | $ sudo systemctl restart network-online.target |
| - | </konsole> | + | </cli> |
| | | ||
| | | ||
| - | <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 | + | $ 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., / | * Locate the XML configuration file of the VM (e.g., / | ||
| * Locate the tag < | * Locate the tag < | ||
| - | <konsole> | + | <code> |
| < | < | ||
| <mac address=' | <mac address=' | ||
| Line 96: | Line 96: | ||
| <address type=' | <address type=' | ||
| </ | </ | ||
| - | </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/ | + | $ ip address add 192.168.1.182/ |
| - | </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 | + | $ 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 | ||
| 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: | ||
| - | <konsole> | + | <cli> |
| - | sudo apt update | + | $ sudo apt update |
| - | </konsole> | + | </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: | ||
| - | <konsole> | + | <cli> |
| - | sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common | + | $ sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common |
| - | </konsole> | + | </cli> |
| - | ===== Step 3: Add Docker' | + | === Step 3: Add Docker' |
| Download and add Docker' | Download and add Docker' | ||
| - | <konsole> | + | <cli> |
| - | curl -fsSL https:// | + | $ curl -fsSL https:// |
| - | </konsole> | + | </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: | ||
| - | <konsole> | + | <cli> |
| - | echo "deb [arch=amd64 signed-by=/ | + | $ echo "deb [arch=amd64 signed-by=/ |
| - | </konsole> | + | </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: | ||
| - | <konsole> | + | <cli> |
| - | sudo apt update | + | $ sudo apt update |
| - | </konsole> | + | </cli> |
| - | ===== Step 6: Install Docker | + | === Step 6: Install Docker === |
| Install Docker on your Debian system: | Install Docker on your Debian system: | ||
| - | <konsole> | + | <cli> |
| - | sudo apt install -y docker-ce docker-ce-cli containerd.io | + | $ sudo apt install -y docker-ce docker-ce-cli containerd.io |
| - | </konsole> | + | </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: | ||
| - | <konsole> | + | <cli> |
| - | sudo usermod -aG docker username | + | $ sudo usermod -aG docker username |
| - | </konsole> | + | </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 | ||
| - | <konsole> | + | <cli> |
| - | newgrp docker | + | $ newgrp docker |
| - | </konsole> | + | </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: | ||
| - | <konsole> | + | <cli> |
| - | sudo docker run hello-world | + | $ sudo docker run hello-world |
| - | </konsole> | + | </cli> |
| - | ====== | + | ====== Backup Script for Proxmox VM ====== |
| Line 236: | Line 236: | ||
| - | ===== 2. Script | + | ===== 2. Running the Backup |
| - | Before running the script, you need to make some adjustments: | + | <cli> |
| - | * Replace ' | ||
| - | * Update / | ||
| - | * Update / | ||
| - | ===== 3. Running the Backup Script ===== | + | #!/bin/bash |
| - | < | + | # Usage function |
| - | DATETIME=`date +\%Y-\%m-\%d_\%H-\%M-\%S` && \ | + | usage() { |
| - | DATABASE=' | + | echo " |
| - | FILESTORE_ARCHIVE=" | + | echo " |
| - | DATABASE_ARCHIVE=" | + | echo " |
| - | EXTRA_ADDONS_ARCHIVE=" | + | echo " |
| - | tar -C / | + | echo " |
| - | tar -C / | + | echo " |
| - | docker exec -i odoo15_db | + | } |
| - | </konsole> | + | |
| + | # 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_ARCHIVE=" | ||
| + | EXTRA_ADDONS_ARCHIVE=" | ||
| + | |||
| + | # Function to log messages to the terminal | ||
| + | log_message() { | ||
| + | echo " | ||
| + | } | ||
| + | |||
| + | # Start logging | ||
| + | log_message " | ||
| + | |||
| + | # Perform the Filestore Backup | ||
| + | log_message " | ||
| + | tar -C " | ||
| + | log_message " | ||
| + | |||
| + | # Perform the Extra Addons Backup | ||
| + | log_message " | ||
| + | tar -C " | ||
| + | log_message "Extra Addons Backup completed." | ||
| + | |||
| + | # Perform the Database Backup | ||
| + | log_message " | ||
| + | docker exec -i " | ||
| + | log_message " | ||
| + | |||
| + | # End logging | ||
| + | log_message " | ||
| + | |||
| + | # Print message to the terminal | ||
| + | echo " | ||
| + | </cli> | ||
| Save the script to a file (e.g., backup_script.sh) and make it executable using the command: | Save the script to a file (e.g., backup_script.sh) and make it executable using the command: | ||
| - | <konsole> | + | <cli> |
| - | chmod +x backup_script.sh | + | $ chmod +x backup_script.sh |
| - | </konsole> | + | </cli> |
| To execute the script, simply run: | To execute the script, simply run: | ||
| - | <konsole> | + | <cli> |
| - | ./ | + | $ ./ |
| - | </konsole> | + | </cli> |
| + | |||
| + | * DATABASE: Name of the Odoo database to backup. | ||
| + | * FILESTORE_DIR: | ||
| + | * EXTRA_ADDONS_DIR: | ||
| + | * POSTGRES_CONT: | ||
| + | * BACKUP_DIR: Path to the backup destination directory. | ||
| - | The script will create three backup files in the current | + | The script will create three backup files in a directory |
| * < | * < | ||
| Line 284: | Line 338: | ||
| * SSH into your Proxmox server as the appropriate user with privileges to manage VMs. | * SSH into your Proxmox server as the appropriate user with privileges to manage VMs. | ||
| * Upload the filestore backup (< | * Upload the filestore backup (< | ||
| + | * Create a file in the filestore/ | ||
| + | <cli> | ||
| + | $ sudo mkdir path/ | ||
| + | </ | ||
| * 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: | ||
| - | <konsole> | + | <cli> |
| - | tar -xzf / | + | $ sudo tar -xzf / |
| - | </konsole> | + | </cli> |
| ===== Step 2: Restore the Extra Addons ===== | ===== Step 2: Restore the Extra Addons ===== | ||
| Line 293: | Line 351: | ||
| * Upload the extra-addons backup (< | * Upload the extra-addons backup (< | ||
| * 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: | ||
| - | <konsole> | + | <cli> |
| - | tar -xzf / | + | $ sudo tar -xzf / |
| - | </konsole> | + | </cli> |
| ===== Step 3: Restore the Database ===== | ===== Step 3: Restore the Database ===== | ||
| * Upload the database backup (< | * Upload the database backup (< | ||
| + | * If the database was completly deleted you need to create the database first by running this command : | ||
| + | |||
| + | <cli> | ||
| + | $ docker exec -i < | ||
| + | </ | ||
| + | |||
| + | Replace < | ||
| + | |||
| * 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: | ||
| - | <konsole> | + | <cli> |
| - | gunzip -c / | + | $ gunzip -c / |
| - | </konsole> | + | </cli> |
| * Replace < | * Replace < | ||
| - | 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. | + | ====== |
| - | If the database | + | - This bash script is designed to automate |
| - | < | ||
| - | docker exec -i odoo15_db createdb -U odoo Database | ||
| - | </ | ||
| - | Replace database with the database name you want to restore | + | ===== 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, | ||
| + | ===== Usage ===== | ||
| + | <cli> | ||
| + | #!/bin/bash | ||
| + | # Function to print log messages | ||
| + | log_message() { | ||
| + | echo " | ||
| + | } | ||
| + | # Function to decompress and restore filestore backup | ||
| + | restore_filestore() { | ||
| + | log_message " | ||
| + | sudo mkdir -p " | ||
| + | sudo tar -xzf " | ||
| + | log_message " | ||
| + | } | ||
| + | # Function to decompress and restore extra-addons backup | ||
| + | restore_extra_addons() { | ||
| + | log_message " | ||
| + | sudo tar -xzf " | ||
| + | log_message "Extra Addons Restore completed." | ||
| + | } | ||
| + | # Function to restore the database | ||
| + | restore_database() { | ||
| + | log_message " | ||
| + | docker exec -i " | ||
| + | gunzip -c " | ||
| + | log_message " | ||
| + | } | ||
| + | # Check the number of arguments | ||
| + | if [ $# -ne 5 ]; then | ||
| + | echo " | ||
| + | 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_ARCHIVE=" | ||
| + | EXTRA_ADDONS_ARCHIVE=" | ||
| + | |||
| + | # Backup date and time | ||
| + | DATETIME=$(date +\%Y-\%m-\%d_\%H-\%M-\%S) | ||
| + | |||
| + | # Start restoring the backups | ||
| + | log_message " | ||
| + | |||
| + | # 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 " | ||
| + | |||
| + | # Print message to the terminal | ||
| + | echo " | ||
| + | |||
| + | </ | ||
| + | |||
| + | * Save the script in a file named restore_script.sh. | ||
| + | * Make the script executable with the following command: | ||
| + | <cli> | ||
| + | $ chmod +x restore_script.sh | ||
| + | </ | ||
| + | |||
| + | * Execute the script with the required arguments: | ||
| + | |||
| + | <cli> | ||
| + | $ ./ | ||
| + | </ | ||
| + | |||
| + | * DATABASE: Name of the Odoo database to restore. | ||
| + | * FILESTORE_DIR: | ||
| + | * EXTRA_ADDONS_DIR: | ||
| + | * POSTGRES_CONT: | ||
| + | * BACKUP_DIR: Path to the directory containing the backup files. | ||
| + | |||
| + | ===== Example ===== | ||
| + | |||
| + | <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:// | ||
| + | === GRANT ALL PREVILEGES TO A USER === | ||
| + | <cli> | ||
| + | GRANT USAGE ON SCHEMA public TO postgres; | ||
| + | GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres; | ||
| + | GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO postgres; | ||
| + | ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO postgres; | ||
| + | ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON SEQUENCES TO postgres; | ||
| + | |||
| + | </ | ||
| + | ===Command to Stop Spoofing Attacks === | ||
| + | <cli> | ||
| + | sudo iptables -A INPUT -p udp --dport 53 -m recent --name dns_flood --set | ||
| + | |||
| + | sudo iptables -A INPUT -p udp --dport 53 -m recent --name dns_flood --update --seconds 60 --hitcount 10 -j DROP | ||
| + | |||
| + | </ | ||
| + | this should limit the number of queries to 10 per second | ||