You are not logged in.
I am trying to setup my computer to automatically backup my home folder to an online service at rsync.net.
I created an ssh pair as a user (not root) to link to the online account.
When I logon to my computer as that user and execute the following script, everything syncs correctly.
rsync -aAXHzv --delete --exclude-from=/home/username1/programming/rsync/exclusionList.txt /home/username1/ username2@accountname:.ssh/foldername/When I set up the timer, service, and script that I am running I get a "Permission Denied" error (details below).
This is the first time I've done anything like this and I'm getting my permissions mixed up.
My thinking was that by adding User= and Group= to the [Service] section of the .service, the script would fire as the user (not root) and authenticate with the user-defined .ssh credentials when trying to connect with rsync.net... but I'm not sure I'm even getting that far.
backup-home.timer
[Unit]
Description=Run backup-home.sh once every hour.
[Timer]
# Time to wait after booting before running for the first time.
OnBootSec=10min
#Time between consecutive runs.
OnUnitActiveSec=1h
Unit=backup-home.service
[Install]
WantedBy=multi-user.target
# located in /usr/lib/systemd/system/backup-home.timer
# points to /etc/systemd/system/multi-user.target.wantsbackup-home.service
[Unit]
Description=Script to backup the Home directory.
[Service]
Type=simple
ExecStart=/usr/local/bin/backup-home.sh
User=rhurdle
Group=rhurdle
# located in /usr/lib/systemd/systembackup-home.sh
#!/bin/bash
# rsync [OPTION...] SRC [DEST]
rsync -aAXHzv --delete --exclude-from=/home/username1/programming/rsync/exclusionList.txt /home/username1/ username2@accountname:.ssh/foldername/
# located in /usr/local/binThe journal entry when the error occurs is:
Aug 13 14:51:28 computername systemd[1]: Started Script to backup the Home directory..
Aug 13 14:51:28 computername systemd[827]: backup-home.service: Failed to execute command: Permission denied
Aug 13 14:51:28 computername systemd[827]: backup-home.service: Failed at step EXEC spawning /usr/local/bin/backup-home.sh: Permission denied
Aug 13 14:51:28 computername systemd[1]: backup-home.service: Main process exited, code=exited, status=203/EXEC
Aug 13 14:51:28 computername systemd[1]: backup-home.service: Failed with result 'exit-code'.It feels like I am very close and I'm missing something very, very simple. A nudge in the right direction would be greatly appreciated.
Cheers,
Last edited by dakota (2018-08-14 02:29:42)
"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb
Offline
What are the exact permissions and ownership of /usr/local/bin/backup-home.sh? Post the output of
ls -l /usr/local/bin/backup-home.shI'm not sure, but it looks like the script itself doesn't get executed, so it doesn't even make it to the rsync command inside the script. You could easily test that by commenting out the rsync statement inside the script and see if there is no error thrown anymore. But I get the sense you still get the same error. If so, log into the user account and run the *script*, not the rsync command inside the script and see if you get the same error.
Offline
What are the exact permissions and ownership of /usr/local/bin/backup-home.sh? Post the output of
ls -l /usr/local/bin/backup-home.shI'm not sure, but it looks like the script itself doesn't get executed, so it doesn't even make it to the rsync command inside the script. You could easily test that by commenting out the rsync statement inside the script and see if there is no error thrown anymore. But I get the sense you still get the same error. If so, log into the user account and run the *script*, not the rsync command inside the script and see if you get the same error.
Yes. I just figured this out and was hoping I could post the solution before any body else realised how stupid I was. ![]()
I created the script file as root and the default permissions were 744. When I changed the permissions to 755, it fired correctly.
-rwxr--r-- 1 root root 215 Aug 13 19:00 /usr/local/bin/backup-home.shI got all flummoxed when I couldn't get the ssh permissions to work. Then, when I got them to work, I was thinking this was still part of the ssh problem and so missed the obvious solution. ![]()
Thank you very much!
Cheers,
Last edited by dakota (2018-08-14 02:41:26)
"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb
Offline