在Linux系統中,數據備份與恢復是非常重要的任務,以確保數據的安全性和系統的可恢復性。以下是一些常用的備份和恢復方法:
使用dd命令備份和恢復分區:
# 備份分區
dd if=/dev/sdaX of=/backup/partition.img bs=4M
# 恢復分區
dd if=/backup/partition.img of=/dev/sdaX bs=4M
使用tar命令備份和恢復分區:
# 備份分區
tar -czvf /backup/partition.tar.gz /path/to/partition
# 恢復分區
tar -xzvf /backup/partition.tar.gz -C /path/to/restore
使用rsync命令備份和恢復分區:
# 備份分區
rsync -avz /path/to/partition/ /backup/partition/
# 恢復分區
rsync -avz /path/to/partition/ /path/to/restore/
使用ddrescue命令恢復損壞的磁盤:
ddrescue /dev/sda /backup/partition.img /backup/partition.log
使用TestDisk恢復分區表:
sudo apt-get install testdisk
testdisk
使用Clonezilla進行備份和恢復:
使用Timeshift進行備份和恢復:
# 備份分區
sudo timeshift --create --comments "backup snapshot"
# 恢復分區
timeshift
文件/數據恢復:
使用extundelete恢復誤刪文件:
extundelete /dev/sda1 --restore-file /path/to/deleted/file.txt
使用photorec/TestDisk恢復丟失的文件:
photorec /dev/sda
系統啟動故障恢復:
分區與磁盤修復:
使用fsck修復文件系統錯誤:
sudo fsck -y /dev/sda1
使用TestDisk修復分區表:
testdisk
系統配置恢復:
通過上述方法,你可以根據具體需求選擇合適的備份策略來保護你的數據。