# Weekly or daily backup of database?

**URL:** https://discuss.tryton.org/t/weekly-or-daily-backup-of-database/5202
**Category:** Developer
**Created:** [April 25, 2022, 7:27am UTC](https://discuss.tryton.org/t/weekly-or-daily-backup-of-database/5202 "2022-04-25T07:27:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![deathrake](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@deathrake](https://discuss.tryton.org/u/deathrake)
#### Post date: [April 25, 2022, 7:27am UTC](https://discuss.tryton.org/t/weekly-or-daily-backup-of-database/5202/1 "2022-04-25T07:27:58Z")

</div>

Hey all  
i was thinking that if tryton had some internal facility for backup on daily basis ?  
currently i am using docker containers . can you please recommend me a way for taking backup of database and also restore the same

Thank you

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [April 25, 2022, 7:46am UTC](https://discuss.tryton.org/t/weekly-or-daily-backup-of-database/5202/2 "2022-04-25T07:46:54Z")

</div>

> [@deathrake](#):
>
> i was thinking that if tryton had some internal facility for backup on daily basis ?

No, tryton has no facility to backup or restore databases. That should be done directly on the database engine.

> [@deathrake](#):
>
> can you please recommend me a way for taking backup of database and also restore the same

If you are using postgres, you can use [pg\_dump](https://www.postgresql.org/docs/current/app-pgdump.html) and [pg\_restore](https://www.postgresql.org/docs/current/app-pgrestore.html)

---

<div class="post-metadata">

### Author: ![dalers](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/dalers/32/1767_2.png) [@dalers](https://discuss.tryton.org/u/dalers)
#### Post date: [April 30, 2022, 4:12am UTC](https://discuss.tryton.org/t/weekly-or-daily-backup-of-database/5202/3 "2022-04-30T04:12:52Z")

</div>

> [@pokoli](#):
>
> If you are using postgres, you can use [pg\_dump](https://www.postgresql.org/docs/current/app-pgdump.html) and [pg\_restore](https://www.postgresql.org/docs/current/app-pgrestore.html)

Here are snippets from my PostgreSQL backup and restore scripts. I run the backup script nightly using cron (or manually before I do something in my sandbox database in case something unexpected happens).

**Backup**

```auto
# Default pg_dump output format is text (SQL), which requires using psql to restore.
# Use --format=c (binary format) to restore using pg_restore.
pg_dump --verbose --host=localhost --port=5432 --username=tryton --dbname=scc --clean --create --format=c --file=/home/dale/backup/scc.dump

```

**Restore**

```auto
# must use --format=c with pg_dump (default pg_dump output format is text (SQL), which
# cannot be restored using pg_restore).
pg_restore --verbose --host=localhost --username=tryton --clean --dbname=scc --username=tryton /home/dale/backup/scc.dump

```
