vault backup: 2024-12-15 15:57:01
This commit is contained in:
25
2024/Postgres Backups and ZFS snapshots.md
Normal file
25
2024/Postgres Backups and ZFS snapshots.md
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
* https://github.com/jibudata/amberapp/blob/34852920052c58f3d518a28e4d09a50584cf40f8/pkg/postgres/postgres.go
|
||||
* Quiesce & Unquiesce
|
||||
* https://zrepl.github.io/v0.2.1/configuration/snapshotting.html#postgres-checkpoint-hook
|
||||
* https://www.postgresql.org/docs/16/wal-reliability.html
|
||||
* https://www.postgresql.org/docs/15/functions-admin.html
|
||||
|
||||
```go
|
||||
func takeSnapshot(db *sql.DB, dataset string, height int, tag string) error {
|
||||
log.Printf("Taking a ZFS snapshot: %s@%d%s", dataset, height, tag)
|
||||
log.Printf(" calling pg_backup_start('blkchain', true)") // pg < 15 use pg_start_backup
|
||||
if _, err := db.Exec(`SELECT pg_backupstart('blkchain', true)`); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf(" executing COPY (SELECT) TO PROGRAM 'zfs snapshot %s@%d%s'", dataset, height, tag)
|
||||
if _, err := db.Exec(fmt.Sprintf(`COPY (SELECT) TO PROGRAM 'zfs snapshot %s@%d%s'`, dataset, height, tag)); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf(" calling pg_backup_stop()") // pg < 15 use pg_stop_backup
|
||||
if _, err := db.Exec(`SELECT pg_backup_stop()`); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user