使用 rsync 命令时权限被拒绝(13)

使用 rsync 命令时权限被拒绝(13)

我正在尝试编写一个脚本,该脚本最终将进入 crontab 并每隔一段时间执行一次。我想将目录从我的硬盘备份到我的 USB 驱动器。以下是脚本:


SOURCE_DIR="/home/user/mc-server-files"
BACKUP1="/home/user/sandisk-usb"

rsync -urDvz --delete "$SOURCE_DIR" "$BACKUP1"

在放入 crontab 之前,我想测试一下,但是当我运行脚本时,source /home/user/scripts/3day-san-backup.sh我得到了以下信息

sending incremental file list
rsync: [generator] recv_generator: mkdir "/home/user/sandisk-usb/mc-server-files" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
mc-server-files/

sent 37,588 bytes  received 338 bytes  75,852.00 bytes/sec
total size is 2,099,733,334  speedup is 55,363.95
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.2.7]

我自己创建目录后,我又遇到了一些错误:

sending incremental file list
mc-server-files/banned-ips.json
mc-server-files/banned-players.json
mc-server-files/bukkit.yml
mc-server-files/commands.yml
mc-server-files/eula.txt
mc-server-files/help.yml
mc-server-files/ops.json
mc-server-files/permissions.yml
mc-server-files/server-icon.png
mc-server-files/server.properties
mc-server-files/spigot.yml
mc-server-files/usercache.json
mc-server-files/version_history.json
mc-server-files/whitelist.json
rsync: [generator] recv_generator: mkdir "/home/user/sandisk-usb/mc-server-files/cache" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
rsync: [generator] recv_generator: mkdir "/home/user/sandisk-usb/mc-server-files/config" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***

还有更多输出,但不适合这里。我需要更改哪些权限?

此外,以下是来自的权限ls -l

drwxrwxrwx+ 11 mc-runner minecraft-runners  4096 Jun 18 15:41 mc-server-files

mc-runner 无法运行 sudo 命令,但我的用户(可以运行 sudo)属于 minecraft-runners 组

相关内容