2
I set the server to run a cronjob and run the script that backs up Gitlab.
Gitlab in turn generates the files .tar
in the briefcase var/opt/gitlab/backups
The first problem is that to access the folder mentioned above, I have to access using the sudo -i
.
The second is that I need to configure crontab to sync the files in the folder var/opt/gitlab/backups
to the external disk /media/<user>/usbbackup/
.
How to configure crontab to perform the above action?
I tried this but error saying it is not allowed to write in the directory. What I really want is a copy of the files. tar and do not change directory. Thanks.
– Filipe Moraes
You can then add
&& rsync -a /var/opt/gitlab/backups/ /media/<user>/usbbackup
crontab command. That way, when the backup finishes the copy will be done.– alejdg
But to use the
rsync
I don’t need to use thesudo
?– Filipe Moraes
You do not need sudo. You only need permission to write and read in the directories with the user who is running the commands.
– alejdg
I executed the
sudo -i
to switch to the root account and only then can I run rsync manually. The question is: crontab runs as root?– Filipe Moraes
By default yes. But it is possible to change the user and even ensure that it runs as root in this way:
0 0 * * * root rsync -a /var/opt/gitlab/backups/ /media/<user>/usbbackup
. If you want to exchange the user replace theroot
by the desired user.– alejdg