Skip to content

togo-framework/backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

togo

togo-framework/backup

marketplace pkg.go.dev MIT

Scheduled DB + files backups for togo — archive, retain, restore.

Install

togo install togo-framework/backup

The 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.

Configuration

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,
})

Usage

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 retention

Schedule it

scheduler.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

REST API

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/mysqldump must be on PATH for the respective drivers; sqlite is copied directly. Archives extract path-traversal-safe.


Premium sponsors

ID8 Media  ·  One Studio

Support togo — become a sponsor.

About

togo backups — scheduled DB + files archives to storage, retention & restore

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Sponsor this project

 

Packages

 
 
 

Contributors

Languages