togo install togo-framework/backupThe togo answer to Spatie Backup. Bundle a database dump + configured files into a single .tar.gz, keep the newest N, and restore on demand. Pair with scheduler to back up on a cadence.
| Env | Description |
|---|---|
BACKUP_SOURCES |
comma-separated directories/files to include |
BACKUP_DB_DRIVER |
postgres | mysql | sqlite (omit to skip the DB) |
BACKUP_DB_DSN |
DB connection string, or the sqlite file path |
BACKUP_DIR |
output directory for archives (default backups) |
BACKUP_KEEP |
retention — keep the newest N archives (0 = keep all) |
Or configure in code:
b, _ := backup.FromKernel(k)
b.Configure(backup.Config{
Sources: []string{"storage/app", "uploads"},
DBDriver: "postgres", DBDSN: os.Getenv("DATABASE_URL"),
Dir: "backups", Keep: 7,
})rec, err := b.Run(ctx) // create a backup now → *Backup{ID, Path, Size, ...}
list := b.List() // newest first
b.Restore(rec.ID, "/restore") // extract the archive (DB restore is a manual psql/mysql step)
b.Prune() // enforce retentionscheduler.Register("backup", func(ctx context.Context) error {
b, _ := backup.FromKernel(k); _, err := b.Run(ctx); return err
})
sched.Schedule("backup", scheduler.DailyAt(3, 0)) // 03:00 nightly| Method | Path | Description |
|---|---|---|
POST |
/api/backup/run |
create a backup now |
GET |
/api/backup/backups |
list backups (newest first) |
GET |
/api/backup/backups/{id} |
one backup record |
pg_dump/mysqldumpmust be onPATHfor the respective drivers; sqlite is copied directly. Archives extract path-traversal-safe.