Use binary store for postgres backups
This commit is contained in:
parent
147b70a26d
commit
8e138819a6
@ -46,7 +46,7 @@ func BackupPostgres(file string, hostname string, database string, username stri
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer os.Remove("/output/.pgpass")
|
defer os.Remove("/output/.pgpass")
|
||||||
cmd := exec.Command(pg_dumpExec, "--clean", "--create", "--file", file, "--host", hostname, "--dbname", database, "--username", username, "--no-password")
|
cmd := exec.Command(pg_dumpExec, "--format=custom", "--clean", "--create", "--file", file, "--host", hostname, "--dbname", database, "--username", username, "--no-password")
|
||||||
cmd.Env = append(os.Environ(), "PGPASSFILE=/output/.pgpass")
|
cmd.Env = append(os.Environ(), "PGPASSFILE=/output/.pgpass")
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
log.V(1).Info("postgres backup output", "output", string(output))
|
log.V(1).Info("postgres backup output", "output", string(output))
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
//psqlExec = "/usr/bin/psql"
|
||||||
pg_restoreExec = "/usr/bin/pg_restore"
|
pg_restoreExec = "/usr/bin/pg_restore"
|
||||||
logger logr.Logger
|
logger logr.Logger
|
||||||
)
|
)
|
||||||
@ -32,6 +33,7 @@ func RestoreVolume(snapshotId string) error {
|
|||||||
log.Error(err, "unable to restore volume", "output", string(output))
|
log.Error(err, "unable to restore volume", "output", string(output))
|
||||||
state = formolv1alpha1.Failure
|
state = formolv1alpha1.Failure
|
||||||
}
|
}
|
||||||
|
log.V(1).Info("restic restore output", "output", string(output))
|
||||||
session.RestoreSessionUpdateTargetStatus(state)
|
session.RestoreSessionUpdateTargetStatus(state)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -44,7 +46,8 @@ func RestorePostgres(file string, hostname string, database string, username str
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer os.Remove("/output/.pgpass")
|
defer os.Remove("/output/.pgpass")
|
||||||
cmd := exec.Command(pg_restoreExec, "--clean", "--create", "--file", file, "--host", hostname, "--dbname", database, "--username", username, "--no-password")
|
//cmd := exec.Command(psqlExec, "--file", file, "--host", hostname, "--dbname", database, "--username", username, "--no-password")
|
||||||
|
cmd := exec.Command(pg_restoreExec, "--format=custom", "--clean", "--host", hostname, "--dbname", database, "--username", username, "--no-password", file)
|
||||||
cmd.Env = append(os.Environ(), "PGPASSFILE=/output/.pgpass")
|
cmd.Env = append(os.Environ(), "PGPASSFILE=/output/.pgpass")
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
log.V(1).Info("postgres restore output", "output", string(output))
|
log.V(1).Info("postgres restore output", "output", string(output))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user