Help to setup cronjob with enviroment variables
Posted: Thu Aug 23, 2018 9:30 pm
Hello, I started to use VestaCP a few weeks now, and I'm just testing and making configurations before migrate my websites to a VPS.
Righ now I'm trying to setup an automated backup using restic and cron.
I installed restic and configure it with success in my server, but all the configuration was done using the root user, not the admin user. And I think that's was part of the problem.
When I configured using the root I added the environment variables to this file: and I can run this command:
My first attempt was to just add a cron using the VestaCP panel to run this command.
I can see in the log using cat /var/log/cron that the cron ran but when use the restic snapshot to list the history of backups no new snapshot is created.
Than I started to see some topics in the forum and I tried to run the same command using the admin user, and to resume I can run via ssh this command using the admin user with partial success:
I get two errors:
I tried to add a cron with this command but it didn't work.
When I try to run this command:
The password is asked.
I really tried to fix that but is beyond my knowledge, and I would appreciate some help.
Thanks
Righ now I'm trying to setup an automated backup using restic and cron.
I installed restic and configure it with success in my server, but all the configuration was done using the root user, not the admin user. And I think that's was part of the problem.
When I configured using the root I added the environment variables to this file:
Code: Select all
/root/.bash_profile
Code: Select all
restic backup /home --exclude /home/backup
I can see in the log using cat /var/log/cron that the cron ran but when use the restic snapshot to list the history of backups no new snapshot is created.
Than I started to see some topics in the forum and I tried to run the same command using the admin user, and to resume I can run via ssh this command using the admin user with partial success:
Code: Select all
restic backup /home --exclude /home/backup
Code: Select all
error: Open: open /home/admin/conf/dns: permission denied
error: Open: open /home/admin/conf/web: permission denied
When I try to run this command:
Code: Select all
sudo restic backup /home --exclude /home/backup
I really tried to fix that but is beyond my knowledge, and I would appreciate some help.
Thanks