在 ntfs 硬碟上備份 Linux 伺服器

在 ntfs 硬碟上備份 Linux 伺服器

我正在尋找一種方法來備份我的 Debian 伺服器。對於資料分割區,我有一個使用 rsync 的解決方案,備份到加密的 ntfs 磁碟機。 NTFS 因為我經常帶著驅動器在 Windows 筆記型電腦上觀看一些電影等。

使用 rsync 備份系統不起作用,因為權限未保留在 ntfs 上。我正在考慮tar存檔,但該--update標誌僅添加新文件,而不會刪除不再存在的文件。

有沒有辦法獲得一些不錯的容器內備份,保留可更新的權限,例如 rsync 更新?

答案1

滿足您的儲存要求的一種方法是建立一個環回檔案系統在 NTFS 分割區內,但問題是這種循環設備的效能會更差,因為輸入輸出 (I/O) 會發生在檔案系統內的檔案系統中。

設定環回檔案系統相當簡單。假設這/demo是您安裝 NTFS 設備的位置:

建立一個空白的非稀疏文件

尺寸由您選擇。我的例子是 1GiB 大:

root@node51 [/demo]# dd if=/dev/zero of=loopback.img bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 1.88537 s, 570 MB/s

使用具有您需要的所有權限功能的檔案系統格式化文件

我在這個例子中使用 ext4:

root@node51 [/demo]# mkfs.ext4 loopback.img
mke2fs 1.42.9 (4-Feb-2014)
loopback.img is not a block special device.
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

您剛剛在文件內建立了一個檔案系統。

掛載新檔案系統

root@node51 [/demo]# mount -o loop loopback.img /mnt

將資料放入新的檔案系統中

root@node51 [/demo]# echo "Data data data" > /mnt/file.txt
root@node51 [/demo]# ll /mnt/
total 28
drwxr-xr-x  3 root root  4096 May 25 09:31 ./
drwxr-xr-x 24 root root  4096 May 25 09:29 ../
-rw-r--r--  1 root root    15 May 25 09:31 file.txt
drwx------  2 root root 16384 May 25 09:30 lost+found/

您可以方便地非常靈活地調整 ext4 檔案系統的大小。

放大範例

root@node51 [/demo]# ll -h
total 33M
drwxr-xr-x  2 root root 4.0K May 25 09:30 ./
drwxr-xr-x 24 root root 4.0K May 25 09:29 ../
-rw-r--r--  1 root root 1.0G May 25 09:31 loopback.img

root@node51 [/demo]# umount loopback.img

root@node51 [/demo]# e2fsck -f loopback.img
e2fsck 1.42.9 (4-Feb-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
loopback.img: 12/65536 files (0.0% non-contiguous), 12636/262144 blocks
root@node51 [/demo]# resize2fs loopback.img 4G
resize2fs 1.42.9 (4-Feb-2014)
Resizing the filesystem on loopback.img to 1048576 (4k) blocks.
The filesystem on loopback.img is now 1048576 blocks long.

root@node51 [/demo]# ll -h
total 33M
drwxr-xr-x  2 root root 4.0K May 25 09:30 ./
drwxr-xr-x 24 root root 4.0K May 25 09:29 ../
-rw-r--r--  1 root root 4.0G May 25 09:32 loopback.img

收縮範例

root@node51 [/demo]# ll -h
total 33M
drwxr-xr-x  2 root root 4.0K May 25 09:30 ./
drwxr-xr-x 24 root root 4.0K May 25 09:29 ../
-rw-r--r--  1 root root 4.0G May 25 09:32 loopback.img

root@node51 [/demo]# e2fsck -f loopback.img
e2fsck 1.42.9 (4-Feb-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
loopback.img: 12/262144 files (0.0% non-contiguous), 25167/1048576 blocks

root@node51 [/demo]# resize2fs loopback.img 128M
resize2fs 1.42.9 (4-Feb-2014)
Resizing the filesystem on loopback.img to 32768 (4k) blocks.
The filesystem on loopback.img is now 32768 blocks long.

root@node51 [/demo]# ll -h
total 33M
drwxr-xr-x  2 root root 4.0K May 25 09:30 ./
drwxr-xr-x 24 root root 4.0K May 25 09:29 ../
-rw-r--r--  1 root root 128M May 25 09:44 loopback.img

答案2

你可以嘗試達爾(http://dar.linux.free.fr/),因為它具有增量備份功能。尚未嘗試過災難恢復,但普通備份似乎運作得很好。

相關內容