使用 rsync 和 link-dest 从 HFS 到 NTFS

使用 rsync 和 link-dest 从 HFS 到 NTFS

我在使用 rsync 时遇到了问题。

我在 Mac 上,我想将我每天的更改从 HFS+ 分区同步到 NTFS 格式的网络驱动器。

非常简单,除了每次同步每个文件外,一切都进展顺利。

这是我的脚本:

#! /bin/sh

snapshot_dir=/Volumes/USB_Storage/Backups
snapshot_id=`date +%Y%m%d%H%M`

/usr/bin/rsync -a \
  --verbose \
  --delete --delete-excluded \
  --human-readable --progress \
  --one-file-system \
  --partial \
  --modify-window=1 \
  --exclude-from=.backup_excludes \
  --link-dest ../current \
  /Users/tommybergeron/Desktop/Brainpad \
  $snapshot_dir/in-progress

cd $snapshot_dir
rm -rf $snapshot_id
mv in-progress $snapshot_id
rm -f current
ln -s $snapshot_id $snapshot_dir/current

有人能帮我吗?我已经搜索了两个小时,但还是一无所获。

非常感谢。

答案1

-a意味着可能无法正确转换为 NTFS 的权限将被复制和匹配。我只使用-rltD-a意味着-rlptgoD

注意:我使用带有 EXT4 的 Linux 的 rsync,我不知道 HFS 与 NTFS 相比如何。

以下是我用来将一些文件夹备份到可移动 USB 磁盘的完整脚本。这在 Ubuntu 10.4 中运行良好

#!/bin/bash
# Rotated backup from EXT4 to removable NTFS-disc using rsync.
# Four generations are saved and automatically purged each run.
# Generations: current, backups/old, backups/older, backups/oldest.
# This script is stored on and run from the root of the removable disc
# where the backups are stored. Destination paths in the rsync commands
# are relative to current working directory below.

# Purge oldest backup
rm -rf backups/oldest

# Prepare recieving folder.
mkdir inprogress

# Grab new contents. Use rsync to create hard links to files already backed up on media. 
# Note: --link-dest is set relative to dest.
# Note: Since we copy from EXT4 to NTFS we can't use -a. Rights are different in NTFS.
#       If we tried then rsync would copy every file, since rights don't match. 
#       I use -rltD instead of -a. Care must be taken when restoring files!

echo "Backup of Musik is updated with changes since last backup"
rsync -rltD --verbose --modify-window=1 --delete \
      --link-dest=../../current/Musik \
      /home/anders/Musik/ \
      inprogress/Musik

echo "Backup of tv is updated with changes since last backup"
rsync -rltD --verbose --modify-window=1 --delete \
      --link-dest=../../current/tv \
      /home/anders/Video/tv/ \
      inprogress/tv

echo "Backup of Calibre Library is updated with changes since last backup"
rsync -rltD --verbose --modify-window=1 --delete \
      --link-dest="../../current/Calibre Library" \
      "/home/anders/Calibre Library/" \
      "inprogress/Calibre Library"

# Rotate the backups
# mkdir backups (only needed first run)
mv backups/older backups/oldest
mv backups/old backups/older
mv current backups/old
mv inprogress current

echo Done!

运行的示例输出:

anders@anders-desktop:/media/Samsung S2$ ./refresh.sh 
Backup of Musik is updated with changes since last backup
sending incremental file list
./
Artists/
Various Artists/

sent 1787165 bytes  received 3256 bytes  102309.77 bytes/sec
total size is 230838013393  speedup is 128929.46
Backup of tv is updated with changes since last backup
sending incremental file list
./

sent 7558 bytes  received 35 bytes  5062.00 bytes/sec
total size is 64808873338  speedup is 8535344.84
Backup of Calibre Library is updated with changes since last backup
sending incremental file list
./

sent 227427 bytes  received 1883 bytes  91724.00 bytes/sec
total size is 825094709  speedup is 3598.16
Done!

答案2

有一件很简单的事困扰过我多次:确保两台计算机的系统时钟设置为相同的时间。

相关内容