Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled service "backup" fails #298

Open
cmonty14 opened this issue Jan 6, 2024 · 4 comments
Open

Scheduled service "backup" fails #298

cmonty14 opened this issue Jan 6, 2024 · 4 comments

Comments

@cmonty14
Copy link

cmonty14 commented Jan 6, 2024

Hi,
I completed configuration for a scheduled service "backup", however it fails to run.
The service file has this content:

# /etc/systemd/system/resticprofile-backup@profile-default.service
[Unit]
Description=resticprofile backup for profile default in /home/thomas/.config/resticprofile/profiles.conf

[Service]
Type=notify
WorkingDirectory=/home/thomas
ExecStart=/usr/local/bin/resticprofile --no-prio --no-ansi --config /home/thomas/.config/resticprofile/profiles.conf --name default --lock-wait 10m0s backup
Nice=5
Environment="HOME=/root"
Environment="SUDO_USER=thomas"

In my opinion this parameter is wrong:
Environment="HOME=/root"

This conclusion is based on this command running w/o errors:
sudo -u thomas resticprofile --name default backup

Can you please advise how to fix this error?

@jkellerer
Copy link
Collaborator

jkellerer commented Jan 6, 2024

Hi @cmonty14 ,

How did you schedule it?

From the result, I'd assume as user thomas:

cd /home/thomas
sudo resticprofile schedule

  • Can you schedule it as user instead, e.g. schedule without sudo?
  • In addition could you share the systemd log output (the part containing the error when the schedule is started)?

@cmonty14
Copy link
Author

cmonty14 commented Jan 8, 2024

I can't schedule a system job w/o sudo:

thomas@miab:~$ resticprofile schedule
2024/01/09 00:43:20 using configuration file: /home/thomas/.config/resticprofile/profiles.conf
2024/01/09 00:43:20 error creating job default/backup: user is not allowed to create a system job: please restart resticprofile as root (with sudo)
thomas@miab:~$ 

As a workaround I modified resticprofile-backup@profile-default.service:

[...]
Environment="HOME=/home/thomas"
Environment="SUDO_USER=thomas"

And here's the full output of system log containing the error:

Jan 06 01:01:38 mydomain.example systemd[1]: Starting resticprofile backup for profile default in /home/thomas/.config/resticprofile/profiles.conf...                                                                                               
Jan 06 01:01:38 mydomain.example systemd[1]: Started resticprofile backup for profile default in /home/thomas/.config/resticprofile/profiles.conf.                                                                                                  
Jan 06 01:01:38 mydomain.example resticprofile[221065]: 2024/01/06 01:01:38 profile 'default': starting 'backup'      
Jan 06 01:01:39 mydomain.example resticprofile[221065]: rclone: <5>NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults                                                                                                
Jan 06 01:01:39 mydomain.exampleresticprofile[221065]: rclone: Failed to create file system for "cloud.mydomain.example:/Backup/restic/miab": didn't find section in config file                                                                
Jan 06 01:01:39 mydomain.example resticprofile[221065]: Fatal: unable to open repository at rclone:cloud.mydomain.example:/Backup/restic/miab: error talking HTTP to rclone: exit status 1                                                      
Jan 06 01:01:39 mydomain.example resticprofile[221065]: 2024/01/06 01:01:39 backup on profile 'default': exit status 1
Jan 06 01:01:39 mydomain.example systemd[1]: resticprofile-backup@profile-default.service: Main process exited, code=exited, status=1/FAILURE                                                                                                       
Jan 06 01:01:39 mydomain.example systemd[1]: resticprofile-backup@profile-default.service: Failed with result 'exit-code'.  

@jkellerer
Copy link
Collaborator

While it should be possible to create schedules for a user (it is actually implemented), the problem you have is related to a missing rclone config for root (the user the job is running with).

Could you check the output of "resticprofile --trace schedule" to get more details on the attempt to schedule as user thomas?

@cmonty14
Copy link
Author

What exactly do you request from output of resticprofile --trace schedule?
Must I create a rclone config for root user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants