Skip to content

Instantly share code, notes, and snippets.

@wesort
Last active September 29, 2026 12:26
Show Gist options
  • Select an option

  • Save wesort/dfbf15e892e8df1708cdd0c0ee73c74a to your computer and use it in GitHub Desktop.

Select an option

Save wesort/dfbf15e892e8df1708cdd0c0ee73c74a to your computer and use it in GitHub Desktop.
Automatic daily backup from production site to GitHub
#!/usr/bin/env bash
# Commit control-panel edits on this server back to the branch it tracks, and push.
# Scheduled in Laravel Forge at server level, likely for prod only, with one of these commands:
# Non zero-downtime: `cd ~/example.com && ./autobackup.sh > /dev/null`
# Zero-downtime: `cd ~/example.com/current && ./autobackup.sh > /dev/null`
# Frequency of cron: `0 */4 * * *` for every 4 hours, or `0 3 * * *` for nightly.
git add -A -- content users resources public
# Optional commit author (client most likely), with committer set at `~/.gitconfig` (most likely lead developer)
git commit --author="example <test@example.com>" -m "[BOT] Automatic backup via cronjob"
git push
# Instructions
# https://gist.github.com/wesort/dfbf15e892e8df1708cdd0c0ee73c74a
@wesort

wesort commented Aug 16, 2019

Copy link
Copy Markdown
Author

Example implementation using Scheduler in Laravel Forge

cd ~/example.com/ && ./autobackup.sh > /dev/null

cronjob-example-01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment