-
-
Notifications
You must be signed in to change notification settings - Fork 9
Setup Periodic Backups
There are mainly two ways to set up periodic backups for git-sync:
- Use the
--cron
flag or thecron
option in the config file to set up git-sync in cron mode. - Use the default flags and set up cronjobs yourself on your system.
With the 0.7.0 release, we now have a dedicated option to run git-sync in cron mode. All you need to do is to add the cron
option in your config file or use the --cron
flag.
If you are using --cron
option, you need to ensure that the service is always running in the background. For that you can use SystemD service to keep running it in background. You can find the example gitsync.service
file and instructions of setting it up here
Apart from running it via SystemD, you can also opt to run git-sync via Docker.
If you don't want to use the in-built --cron
option, you can still go ahead and setup cronjobs on your system directly to run git-sync periodically. Here are few ways to setup cron job based on different operating system.
You can set up periodic backups using cron jobs or systemD timers. For example, to back up your repositories every day at 12:00 AM, you can add the following cron job:
0 0 * * * /path/to/git-sync
Replace /path/to/git-sync
with the path to the git-sync
binary.
You can set up periodic backups using Task Scheduler. Here's how you can do it:
- Open Task Scheduler.
- Click on
Create Basic Task
. - Enter a name and description for the task.
- Choose the trigger (e.g.,
Daily
). - Set the time for the trigger.
- Choose
Start a program
as the action. - Browse to the
git-sync
binary. - Click
Finish
to create the task. - Right-click on the task and select
Run
to test it. - Your repositories will now be backed up periodically.
Or you can use Powershell script to run the git-sync
binary.
$action = New-ScheduledTaskAction -Execute "path\to\git-sync.exe"
$trigger = New-ScheduledTaskTrigger -Daily -At "12:00AM"
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "GitSyncTask" -Description "Daily Git Sync"
Replace path\to\git-sync.exe
with the path to the git-sync
binary.