1

I backed up my Ubuntu 14.04 system using rsync to a USB stick, but apparently it wasn't formatted for booting. The original disk has been erased and I put a fresh install of Ubuntu on it. In migrating my data I forgot to dump one of my postgres databases to SQL, and I need to migrate it to my new install of Ubuntu.

I'm considering formatting a bootable disk and then attempting to rsync my old system to that for disk so I can boot and dump my database to SQL. But that's a discussion for a different forum.

I'm wondering if it's possible to use the data files from my old system to restore my database (i.e. copy /var/lib/postgresql/9.3/main) from my old install to my new install? Has anyone ever done this? I did try just copying the data file but it caused Postgres to break beyond repair. I had to delete it entirely and reinstall.

I know it's possible with MySQL, but I'm less familiar with Postgres.

Thanks!

1
  • 2
    You can copy the whole data directory and it'll work fine. In Ubuntu you must also copy postgresql.conf and pg_hba.conf from /etc/postgresql, since they're stored outside the PostgreSQL data directory. Please be more specific about "break beyond repair". Commented Jan 7, 2015 at 0:36

1 Answer 1

2

Rsync is a supported backup method for postgresql. However it has some caveats that you need to be aware of. Namely the database should be offline when the sync is done.

So if your database was offline when you synced, you could restore it jsut fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.