Skip to Content
문서운영시스템 관리백업 및 복구

백업 및 복구

데이터 백업은 시스템 관리의 가장 중요한 측면 중 하나입니다. 이 문서에서는 귀하의 요구에 맞는 도구를 선택하는 데 도움이 되는 Ubuntu 26.04의 다양한 백업 및 복구 솔루션을 소개합니다.

rsync - 유연한 동기화 도구

rsync는 증분 전송을 지원하는 빠르고 유연한 파일 동기화 도구이며 Linux에서 가장 일반적으로 사용되는 백업 도구 중 하나입니다.

기본 사용법

# Local directory sync rsync -av /source/directory/ /backup/directory/ # Note: the trailing slash on the source path matters # /source/dir/ -> syncs the contents of the directory # /source/dir -> syncs the directory itself (including the directory name)

공통 옵션

# -a archive mode (preserves permissions, timestamps, symlinks, etc.) # -v verbose output # -z compress during transfer # -h human-readable output # --progress show progress # --delete delete files in the target that don't exist in the source # Complete local backup command rsync -avh --progress /home/user/ /backup/home-user/ # Backup with exclusion rules rsync -avh --progress \ --exclude='.cache' \ --exclude='node_modules' \ --exclude='.local/share/Trash' \ /home/user/ /backup/home-user/ # Using an exclude file rsync -avh --exclude-from='/home/user/rsync-excludes.txt' \ /home/user/ /backup/home-user/

원격 백업

# Backup to a remote server via SSH rsync -avz -e ssh /home/user/ user@remote:/backup/home-user/ # Specify SSH port rsync -avz -e "ssh -p 2222" /home/user/ user@remote:/backup/home-user/ # Restore from a remote server rsync -avz user@remote:/backup/home-user/ /home/user/ # Use --delete to keep both sides in sync rsync -avz --delete /home/user/ user@remote:/backup/home-user/

자동 rsync 백업 스크립트

백업 스크립트를 생성합니다:

sudo nano /usr/local/bin/daily-backup.sh
#!/bin/bash # Configuration SOURCE="/home/" DEST="/backup/daily" LOG="/var/log/backup.log" DATE=$(date +%Y-%m-%d_%H%M%S) # Create log entry echo "===== Backup started: $DATE =====" >> "$LOG" # Execute backup rsync -avh --delete \ --exclude='.cache' \ --exclude='node_modules' \ --exclude='.local/share/Trash' \ "$SOURCE" "$DEST" >> "$LOG" 2>&1 # Record result if [ $? -eq 0 ]; then echo "Backup completed successfully: $(date)" >> "$LOG" else echo "Backup failed: $(date)" >> "$LOG" fi
sudo chmod +x /usr/local/bin/daily-backup.sh

cron으로 예약하세요.

# Run backup every day at 2 AM sudo crontab -e # Add: 0 2 * * * /usr/local/bin/daily-backup.sh

타임시프트 - 시스템 스냅샷

Timeshift는 Windows 시스템 복원과 유사하게 시스템 파일 스냅샷 및 복구에 중점을 둡니다.

설치 및 구성

# Install Timeshift sudo apt install timeshift # Launch the graphical interface sudo timeshift-gtk # Create a snapshot via command line sudo timeshift --create --comments "Before installing NVIDIA driver" # List all snapshots sudo timeshift --list # Restore to a specific snapshot sudo timeshift --restore --snapshot '2026-03-24_10-00-00' # Delete a snapshot sudo timeshift --delete --snapshot '2026-03-24_10-00-00'

명령줄 구성

# View current configuration sudo timeshift --config # Set snapshot type (RSYNC or BTRFS) sudo timeshift --snapshot-device /dev/sda2

타임시프트 구성 파일

/etc/timeshift/timeshift.json 편집:

{ "backup_device_uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "parent_device_uuid": "", "do_first_run": false, "btrfs_mode": false, "include_btrfs_home": false, "schedule_monthly": false, "schedule_weekly": true, "schedule_daily": true, "schedule_hourly": false, "schedule_boot": false, "count_monthly": 2, "count_weekly": 3, "count_daily": 5, "count_hourly": 0, "count_boot": 0, "exclude": [ "/home/**", "/root/**" ] }

Btrfs 스냅샷 모드

시스템이 Btrfs 파일 시스템을 사용하는 경우 Timeshift는 더 빠르고 더 적은 공간을 사용하는 기본 Btrfs 스냅샷을 활용할 수 있습니다.

# Verify filesystem type df -T / # If it's Btrfs, select BTRFS mode in Timeshift sudo timeshift --btrfs

Deja Dup - 데스크탑 백업 도구

Deja Dup(GNOME 백업)은 개인 사용자에게 적합한 Ubuntu 데스크탑 환경을 위한 사용하기 쉬운 백업 도구입니다.

설치 및 사용법

# Install (usually pre-installed on Ubuntu Desktop) sudo apt install deja-dup

Deja Dup은 “설정”을 통해 또는 앱 메뉴에서 “백업”을 검색하여 액세스할 수 있는 그래픽 인터페이스를 제공합니다.

주요 기능:

  • 로컬 디스크, 외부 드라이브 및 네트워크 스토리지에 대한 백업 지원
  • Google 드라이브 및 기타 클라우드 저장소에 대한 백업 지원
  • 백업 자동 암호화
  • 증분 백업 지원
  • 예약된 자동 백업

명령줄 작업

Deja Dup은 이중성을 백엔드로 사용합니다.

# Manually run a backup deja-dup --backup # Restore files deja-dup --restore

디스크 이미지 백업

dd를 사용하여 디스크 이미지 생성

# Create a full disk image sudo dd if=/dev/sda of=/backup/sda.img bs=4M status=progress # Compressed image sudo dd if=/dev/sda bs=4M status=progress | gzip > /backup/sda.img.gz # Restore from an image sudo dd if=/backup/sda.img of=/dev/sda bs=4M status=progress # Restore from a compressed image gunzip -c /backup/sda.img.gz | sudo dd of=/dev/sda bs=4M status=progress

Clonezilla 사용

Clonezilla는 강력한 디스크 복제 및 이미징 도구입니다.

# Install Clonezilla sudo apt install clonezilla # It is generally recommended to boot from a Clonezilla Live USB # Download: https://clonezilla.org/downloads.php

tar를 사용한 시스템 백업

# Back up the entire system (excluding unnecessary directories) sudo tar czpf /backup/system-$(date +%Y%m%d).tar.gz \ --exclude=/backup \ --exclude=/proc \ --exclude=/sys \ --exclude=/dev \ --exclude=/run \ --exclude=/tmp \ --exclude=/mnt \ --exclude=/media \ --exclude=/lost+found \ / # Restore the system sudo tar xzpf /backup/system-20260324.tar.gz -C /

데이터베이스 백업

MySQL/마리아DB

# Back up a single database mysqldump -u root -p database_name > /backup/db-$(date +%Y%m%d).sql # Back up all databases mysqldump -u root -p --all-databases > /backup/all-db-$(date +%Y%m%d).sql # Restore a database mysql -u root -p database_name < /backup/db-20260324.sql

포스트그레SQL

# Back up a single database sudo -u postgres pg_dump dbname > /backup/pg-$(date +%Y%m%d).sql # Back up all databases sudo -u postgres pg_dumpall > /backup/pg-all-$(date +%Y%m%d).sql # Restore sudo -u postgres psql dbname < /backup/pg-20260324.sql

백업 전략 권장 사항

3-2-1 백업 규칙

  • 3 데이터 사본(원본 + 2개의 백업)
  • 2 다양한 저장 매체(예: 로컬 하드 드라이브 + 클라우드 저장소)
  • 1 오프사이트 백업(물리적 재해로부터 보호)

시나리오별 추천

시나리오권장 도구백업 빈도
데스크톱 개인 사용자데자 덥 + 타임시프트일간/주간
개발 워크스테이션rsync + 타임시프트매일
웹 서버rsync + 데이터베이스 백업일별 / 시간별
중요한 비즈니스 서버rsync + LVM 스냅샷 + 오프사이트 백업실시간 / 시간별

백업 확인

정기적으로 백업 무결성을 확인하는 것이 중요합니다.

# Verify a tar backup tar tzf /backup/system-20260324.tar.gz > /dev/null # Verify an rsync backup rsync -avhn --delete /source/ /backup/ # dry-run to compare differences # Perform periodic restore drills
Last updated on