Last active
September 29, 2026 12:26
-
-
Save wesort/dfbf15e892e8df1708cdd0c0ee73c74a to your computer and use it in GitHub Desktop.
Automatic daily backup from production site to GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example implementation using Scheduler in Laravel Forge
cd ~/example.com/ && ./autobackup.sh > /dev/null