# How to make a postgres backup with pg\_backup using xojo app?

**URL:** <https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530>\
**Category:** Databases\
**Created:** [August 26, 2024, 4:05pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530 "2024-08-26T16:05:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 26, 2024, 4:05pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530/1 "2024-08-26T16:05:50Z")

</div>

Hi folks,

I would like to initiate a pg\_backup command on a remote postgres server.  
It seems impossible from a xojo app using postgres plugin, you can only send sql queries ?  
or did I miss something.  
do I need to make a ssh connexion to the remote server and send a shell command ?

thanks.

---

<div class="post-metadata">

**Author:** ![Craig\_Boyd](https://forum.xojo.com/user_avatar/forum.xojo.com/craig_boyd/32/15397_2.png) [@Craig\_Boyd](https://forum.xojo.com/u/Craig_Boyd)\
**Post date:** [August 26, 2024, 4:20pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530/2 "2024-08-26T16:20:21Z")

</div>

Unless something has changed recently, yeah, pg\_backup can only be initiated from the shell.

---

<div class="post-metadata">

**Author:** ![Richard\_Klingler](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_klingler/32/8198_2.png) [@Richard\_Klingler](https://forum.xojo.com/u/Richard_Klingler)\
**Post date:** [August 26, 2024, 4:24pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530/3 "2024-08-26T16:24:27Z")

</div>

Well what I do on my Debian servers is always run a cron job doing a backup (o;

On certain systems even hourly and keep the backups for 30 days…

That way you always get backups even if you’re on vacation or asleep 😉

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 26, 2024, 5:03pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530/4 "2024-08-26T17:03:21Z")

</div>

there are automatic pg\_backup on the server, but sometimes, for testing or more backup purpose, I would like to download a pg\_dump to my local machine, using my xojo client app for that.  
seems it’s not possible, or I would have to recreate a backup of all tables, sequences, roles, using a sequence of queries…

---

<div class="post-metadata">

**Author:** ![Richard\_Klingler](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_klingler/32/8198_2.png) [@Richard\_Klingler](https://forum.xojo.com/u/Richard_Klingler)\
**Post date:** [August 26, 2024, 5:07pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530/5 "2024-08-26T17:07:43Z")

</div>

Then probably there’s only SSH from local machine left and pipe through the pg\_dump command and save the dump locally…

Or…what about a web hook you call with special header tokens for authentication and let the webserver do the dump and send it to you?

---

<div class="post-metadata">

**Author:** ![Craig\_Boyd](https://forum.xojo.com/user_avatar/forum.xojo.com/craig_boyd/32/15397_2.png) [@Craig\_Boyd](https://forum.xojo.com/u/Craig_Boyd)\
**Post date:** [August 26, 2024, 5:44pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530/6 "2024-08-26T17:44:20Z")

</div>

If you can get the SSH connection then you can connect via pgadmin and I _think_ you can have it write the backup files locally.

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [August 26, 2024, 6:15pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530/7 "2024-08-26T18:15:39Z")

</div>

this could be a solution start …

> **[How to use pg\_dump and pg\_restore in multi-host enviorment](https://www.enterprisedb.com/postgres-tutorials/how-use-pgdump-and-pgrestore-multi-host-enviorment)**
>
> You have probably looked at logical dumps as supported by pg\_dump and restores by pg\_restore or, more simply, psql. What you might not have realized are the many options for dumping and restoring when multiple computers are involved.

---

<div class="post-metadata">

**Author:** ![Richard\_Klingler](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_klingler/32/8198_2.png) [@Richard\_Klingler](https://forum.xojo.com/u/Richard_Klingler)\
**Post date:** [August 26, 2024, 6:19pm UTC](https://forum.xojo.com/t/how-to-make-a-postgres-backup-with-pg-backup-using-xojo-app/81530/8 "2024-08-26T18:19:03Z")

</div>

Had a case this year where I needed to migrate our online shop from a Debian 11 machine to a Debian 12 machine…

Only pgAdmin did the job successfully (o;

pg\_restore failed on Debian 12 for the older database version…and even Navicat failed miserably…
