# User friendly time
dmesg --ctime
Monthly Archives: December 2025
bash
#!/usr/bin/env bash
set -euo pipefail
# Get time
NOW=$(date '+%d/%m/%Y %H:%M:%S');
echo "$NOW: Text"dd
Backup / Clone
# clone disk
dd if=/dev/sdX of=/dev/sdY bs=64K conv=noerror,sync status=progress
# backup to file using gzip compression
dd if=/dev/sdX bs=64K conv=noerror,sync status=progress | gzip -c > /PATH/TO/DRIVE/backup_image.img.gz
# restore from file
gunzip -c /PATH/TO/DRIVE/backup_image.img.gz | dd of=/dev/sdX status=progress
# restore from file without gzip
dd if=/PATH/TO/DRIVE/backup_image.img of=/dev/sdX status=progress
# clone only to the end of last partition
SECTOR_SIZE=$(blockdev --getss /dev/sdX)
# LAST_END=start + size - 1
sfdisk -d /dev/sdX
# parameters for dd
bs="$SECTOR_SIZE" count="$LAST_END"
Mount Image
# Scan
losetup --partscan --find --show backup_image.img
# Free-up
losetup -d /dev/loop0
Nginx
Configuration
# HTTP to HTTPS
if ($scheme = http) {
return 301 https://$host$request_uri;
}
# Proxy
location / {
include /etc/nginx/proxy_params;
proxy_pass http://127.0.0.1:5000/;
}
# Custom robots.txt
location = /robots.txt {
add_header Content-Type text/plain;
return 200 "User-agent: *\nDisallow: /\n";
}
# Activate HTTP2 (1.9.5+)
listen 443 ssl http2;
Rate limiting
# Use $http_cf_connecting_ip instead of $binary_remote_addr when behind Cloudflare
limit_req_zone $http_cf_connecting_ip zone=php_limit:10m rate=10r/s;
limit_req_log_level warn;
location ~ \.php$ {
limit_req zone=php_limit burst=50;
}
# Test using bash
for i in $(seq 1 30); do curl -I -s "https://[HOST]/" | head -n 1; done
AutoMySQLBackup
Configuration
```
# Set rotation of daily backups. VALUE*24hours
# If you want to keep only today's backups, you could choose 1, i.e. everything older than 24hours will be removed.
CONFIG_rotation_daily=6
# Set rotation for weekly backups. VALUE*24hours
CONFIG_rotation_weekly=30
# Set rotation for monthly backups. VALUE*24hours
CONFIG_rotation_monthly=90
```
apt
CLI
# Clear package cache
apt clean
# Installed package version
apt list --installed | grep [package]
# Get versions of package
apt-cache policy [package]
Apache
CLI
# Enable modules
a2enmod ssl
a2enmod rewrite
# Disable autoindex
a2dismod autoindex
# Enable default SSL config
a2ensite default-ssl
Configuration
# HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
Upgrade Debian 12 to Debian 13
I use those steps on LXC virtual in Proxmox:
- Make sure all packages are upgraded:
apt update && apt upgrade - Backup container in Proxmox
- Edit release version:
sed -i'.bak' 's/bookworm/trixie/g' /etc/apt/sources.list - Update other configuration files in
/etc/apt/sources.list.d/appropriately - Update packages index:
apt update - Do minimal system upgrade:
apt upgrade --without-new-pkgs - Do full upgrade:
apt full-upgrade - Restart the system:
reboot