You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于Hetzner云平台Ubuntu服务器全量手动备份方法的咨询

Hetzner云平台Ubuntu服务器全量手动备份方法的咨询

Hey there! Let’s break down exactly how to create a full manual backup of your Hetzner Ubuntu server—covering your entire system, all three WordPress sites, and their databases, all wrapped into a single file for when disaster strikes.

两种可行的全量备份方案

方案1:用Hetzner云自带的快照功能(最简单)

If you just need a reliable backup that’s easy to restore directly on Hetzner, their built-in snapshot tool is your best bet—it captures the entire server state in one go:

  • Log into your Hetzner Cloud Console, find your target server.
  • Click the Snapshots tab, then hit Create Snapshot.
  • Give it a descriptive name (like Full-Disaster-Recovery-2024-MM-DD) and wait for the process to finish.
  • This snapshot includes everything: system files, WordPress sites, databases, all configurations. If your server gets deleted later, you can spin up a new server using this snapshot and pick up right where you left off.

方案2:手动打包全量备份(适合本地存储)

If you want a backup file you can download and store locally (or elsewhere), follow these steps to pack everything into one compressed file:

Step 1: Prep for backup

First, stop running services to avoid data inconsistencies (like a WordPress post being written mid-backup):

# Stop your web server (nginx or apache2, use the one you have)
sudo systemctl stop nginx
# Or sudo systemctl stop apache2

# Stop MySQL to freeze database state
sudo systemctl stop mysql

Step 2: Export all WordPress databases

Grab your database credentials from the wp-config.php file of each WordPress site, then export all databases (you can export all at once if you prefer):

# Export all databases to a single SQL file
mysqldump -u YOUR_DB_USERNAME -pYOUR_DB_PASSWORD --all-databases > /tmp/wordpress_backup.sql

Note: Replace YOUR_DB_USERNAME and YOUR_DB_PASSWORD with actual values from your wp-config.php. Skip the space between -p and your password to avoid a prompt.

Step 3: Pack the entire system + databases into one file

Use tar to compress everything, excluding temporary/system virtual directories that don’t need backing up:

sudo tar -cvpzf /full_server_backup.tar.gz \
--exclude=/dev \
--exclude=/proc \
--exclude=/sys \
--exclude=/tmp \
--exclude=/run \
--exclude=/mnt \
--exclude=/media \
--exclude=/lost+found \
--exclude=/full_server_backup.tar.gz \
/ /tmp/wordpress_backup.sql

Let’s break down the flags:

  • -c: Create a new archive
  • -v: Show progress (optional, remove it for faster backup)
  • -p: Preserve file permissions (critical for system recovery)
  • -z: Compress with gzip to save space
  • -f: Specify the output file name

Step 4: Restart your services

Once the backup is done, get your sites back online:

sudo systemctl start mysql
sudo systemctl start nginx
# Or sudo systemctl start apache2

Step 5: Download the backup to your local machine (optional but recommended)

Use scp from your local computer to pull the backup file:

scp your_server_username@your_server_ip:/full_server_backup.tar.gz /path/on/your/local/computer/

How to restore from this backup

If your server gets deleted entirely:

  1. Create a new Ubuntu 20.04/22.04 server (matching your original OS version) on Hetzner.
  2. Upload your backup file to the new server (use scp in reverse).
  3. Unpack the backup:
    sudo tar -xvpzf /full_server_backup.tar.gz -C /
    
  4. Fix any system-specific configs (like network settings or fstab if needed), then reboot the server. You should be back to your original setup.

备注:内容来源于stack exchange,提问作者kobilevi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 10:33:14