Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Take backup for Gitlab periodically

By running sudo gitlab-rake gitlab:backup:create we can create backup for Gitlab manually. But is there any way to take Gitlab backup periodically, like daily or monthly.

PS: I want the backup file to be in Local folder not any cloud storage

like image 561
Rajana Deepak Avatar asked Oct 31 '25 07:10

Rajana Deepak


1 Answers

2018: A good start would be the section "Configuring cron to make daily backups "

To schedule a cron job that backs up your repositories and GitLab metadata, use the root user:

sudo su -
crontab -e

There, add the following line to schedule the backup for everyday at 2 AM:

0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1

Q4 2024: As noted by Esmaeele in the comments

In recent version of Gitlab, we have gitlab-backup binary comand.
So I use this line in crontab to backup gitlab repository each night at 01:00

0 01 * * * /usr/bin/gitlab-backup create SKIP=registry,packages,builds CRON=1

See "Configuring cron to make daily backups"

Default backup keep time is Seven days.
Also as stated in link, we can change in /etc/gitlab/gitlab.rb under the gitlab_rails['backup_keep_time'] = 604800 section.

like image 163
VonC Avatar answered Nov 02 '25 16:11

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!