I am trying to make a script that will eventually go into crontab to execute every once in a while. I want to backup a directory from my HDD to my usb drive. Here is the script:
SOURCE_DIR="/home/user/mc-server-files"
BACKUP1="/home/user/sandisk-usb"
rsync -urDvz --delete "$SOURCE_DIR" "$BACKUP1"
Before putting into crontab, I want to test it, but when I run the script with source /home/user/scripts/3day-san-backup.sh
I get the following
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]
After making the directory myself, I got some more errors:
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 ***
There's more output, but it doesn't fit here. What permissions do I need to change?
Also, here is the permissions from ls -l
:
drwxrwxrwx+ 11 mc-runner minecraft-runners 4096 Jun 18 15:41 mc-server-files
mc-runner cannot run sudo commands, but my user (who can run sudo) is in the minecraft-runners group