rdiff-backup
rdiff-backup เป็นเครื่องมือในการจัดการสำรองข้อมูลให้มีประสิทธิภาพ จะสามารถสำรองข้อมูลโดยมีประวัติย้อนหลัง และสามารถกู้คืนได้ตามวัน เวลาที่ต้องการ
Install rdiff-backup
Server spec. Ubuntu server 24.04.1
คำสั่งติดตั้ง rdiff-backup
bash
apt install rdiff-backupตรวจสอบเวอร์ชั่น
bash
rdiff-backup -V
# rdiff-backup 2.2.6Backup from local
คำสั่งสำรองข้อมูล
bash
# rdiff-backup backup <Options> \
# --exclude <file|directory> \
# <Source path> <Backup path>
rdiff-backup backup --print-statistics \
--exclude=**{log,cache} \
/root/test-rdiff/data/ \
/root/test-rdiff/backup/Backup from server to local
คำสั่งสำรองข้อมูลบนเซิร์ฟเวอร์ต้นทางมายัง directory
TIP
เซิร์ฟเวอร์ต้นทางจะต้องติดตั้ง rdiff-backup ให้เสร็จเรียบร้อย
bash
# rdiff-backup backup <Options> \
# --exclude <file|directory> \
# <Server::path> <Backup path>
rdiff-backup backup --print-statistics \
--exclude=**{log,cache} \
root@server::/mnt/data/ /root/test-rdiff/backup/List backup
คำสั่งแสดงรายการสำรองข้อมูล
bash
# rdiff-backup list increments <Backup path>
rdiff-backup list increments /root/test-rdiff/backup/
# Found 2 increments:
# increments.2024-10-17T13:29:00+07:00.dir Thu Oct 17 13:29:00 2024
# increments.2024-10-17T13:30:03+07:00.dir Thu Oct 17 13:30:03 2024Restore (increment)
คำสั่งการกู้คืนข้อมูลแบบ Increment
bash
# rdiff-backup restore --increment <Backup path>/<Increments Backup> <Restore path>
rdiff-backup restore --increment \
/root/test-rdiff/backup/rdiff-backup-data/increments.xxxx-xx-xxTxx:xx:xx+07:00.dir \
/root/test-rdiff/new/Remove backup
คำสั่งลบข้อมูลที่สำรองไว้
bash
# rdiff-backup --remove-older-than 1D <Backup path>
# rdiff-backup --remove-older-than 1D /root/test-rdiff/backup/
rdiff-backup remove --remove-older-than 1D /root/test-rdiff/backup/Example Restoring (increment)
ตัวอย่างการกู้คืนข้อมูล จะต้องทำการสำรองข้อมูลไว้ก่อน
แสดงรายการข้อมูล
bash
ls data/
# test1.txt test2.txtลบไฟล์ในแฟ้ม data
bash
rm -rf data/*แสดงรายการข้อมูลอีกครั้ง จะไม่พบข้อมูล
bash
ls data/
#ใช้คำสั่งแสดงรายการที่ได้สำรองข้อมูลไว้
bash
rdiff-backup list increments /root/test-rdiff/backup/
# Found 2 increments:
# increments.2024-10-18T08:48:33+07:00.dir Fri Oct 18 08:48:33 2024
# increments.2024-10-18T08:48:59+07:00.dir Fri Oct 18 08:48:59 2024
# Current mirror: Fri Oct 18 08:49:25 2024คำสั่งกู้คืนข้อมูลตามวันเวลา ที่ต้องการ increments.2024-10-18T08:48:59+07:00.dir
bash
rdiff-backup restore --increment \
/root/test-rdiff/backup/rdiff-backup-data/increments.2024-10-18T08:48:59+07:00.dir \
/root/test-rdiff/data/ใช้แสดงรายการข้อมูลอีกครั้ง จะเห็นไฟล์ที่ได้กู้คืนมาเรียบร้อย
bash
ls data/
# test1.txt test2.txt ✨ สนับสนุน💰เป็นกำลังใจ ❤️