A lightweight Go utility for creating scheduled backups of any folder with automatic retention management.
This tool creates timestamped ZIP archives of any specified folder and maintains a configurable backup history. While originally created for backing up Obsidian vaults, it works with any directory you need to preserve.
- Creates compressed ZIP backups of any folder
- Names backups with precise timestamps for easy identification
- Manages backup history automatically (configurable retention)
- Simple to configure, build, and run
- Minimal dependencies
- Cross-platform (Windows, macOS, Linux)
- Go 1.16 or higher
# Clone the repository
git clone https://github.com/binge-coder/Folder-Backup-Utility.git
cd Folder-Backup-Utility
# Install dependencies (automatically fetches required packages)
go mod download
Modify these variables in backup-script.go
to match your requirements:
sourceFolder := `full\path\to\folder\needing\backup` // Any folder you want to back up
backupFolder := `full\path\to\backup\storage` // Where backups will be stored
By default, the script keeps the 4 most recent backups. To change this, modify the condition:
if len(backupFiles) > 4 { // Change to your desired number of backups to keep
// ...
}
# Build the executable
go build -o backup-script.exe
# Run the backup
./backup-script.exe
Use Task Scheduler:
- Open Task Scheduler
- Create a new task
- Set the trigger (daily/weekly/etc.)
- Action: Start a program
- Browse to your
backup-script.exe
location
Use cron:
# Edit crontab
crontab -e
# Add a line to run daily at 2 AM, for example:
0 2 * * * /path/to/backup-script
- Creates the backup folder if it doesn't exist
- Generates a timestamped ZIP file of the source folder
- Counts existing backups and removes the oldest ones if necessary
The script uses the mholt/archiver library for creating ZIP archives. All dependencies will be automatically downloaded when you run go mod download
.
This project is open source and available under the MIT License.