WAL Archive Backup and Restore - postgresql

In a postgresql, how to create WAL archieve ?
Step by step explanation is available for Backup and Restore
using Linux or shell command?
Enviroment :
OS : LINUX RHEL 7.4
DB : Postgresql 9.2
is there any options without stopping postgresql complete backup as well as restore ?

yes, it is described https://www.postgresql.org/docs/9.2/static/continuous-archiving.html
with examples for unix like system.
you dont have to stop postgres to take backup, neither base backup, nor wals

Related

Postrgesql base Backup - older version to New version

Can we take base backup from postgresql old version db to new version db.
For Example I have two DB servers. One server is having old version Postgres 9.x and another one is running Postgres 13.  
If I want to take base backup from postgres 9.x for Postgres 13, can we do that directly using the pg_basebackup command in Postgres 13 DB server.
Is there any other way to complete the above task in Postgres.
I have a plan below to complete the above task if the base backup does not work for lower to higher versions. But it is a slow process.
DB A has a lower version and DB B has a higher version.
So to take base backup, updating the A DB version same as B DB is the only option. 
Once the DB A updated successfully, Then start the base backup from A DB with updated Postgres version to the B DB. 
We can refer to the below site for the DB update process.
https://www.migops.com/blog/upgrading-postgresql-9-6-to-postgresql-13/
The DB update process will take time to complete. In that time the write process will not work on the primary DB.  All the write process will be affected because of this.  If any issue happens in the update process, almost everything will be a mess. 
I will suggest the old version DB to the new version db base backup process  to complete this activity.
Do you guys have any suggestions?
You are mixing up physical file-system level backup (pg_basebackup) and logical backup, also known as dump or export (pg_dump). You can only use the latter for upgrading. A pg_basebackup can only be restored to the same major PostgreSQL version.

Restoring PostgreSQL database without having a dump just the database files

My hoster upgraded my Ubuntu server and it's not booting any more. The only way I can access my data any more is in read mode via a rescue environment (SSH shell).
I am running a postgres 9.1 installation on the crashed server. I am not able to start the postgres server in the rescue environment. I also do not have a dababase dump created with pg_dump.
However, I was able to copy the whole /var/lib/postgresql folder to a new machine . I installed Postgres 9.1 on this machine. Afertwards I replaced the /var/lib/postgresql with my old files.
When I start the postgres server, I get something like "incorrect checksum in control file".
I there any way to restore the database content without using pg_dump (since I don't have a current dump and I am not able to run it on the defective machine).
Indeed it was an issue between 32bit and 64bit. I had another old server running on 32bit Ubuntu. Initially I tried to restore the data on a 64bit machine. With the 32bit machine it simply worked by copying the postgres main directory. Finally I was able to log into the database and create a dump.

postgreSQL backup restoration using bkp.tar.gz file

I am an Oracle DBA and I got a bkp.tar.tgz PostgreSQL backup file to restore on server. Vendor provided backup file before closing contract. I don't have any information for backup file.
I have below questions.
PostgreSQL backup can be restored on cross platform OS? If no, then how can I know what is source OS.
PostgreSQL db version needs to be same? Or doesn't matter? How to find db version from bkp file? They said it's PostgreSQL 9.4.5
Is there any other way I can access data from backup file?

vCSA 5.5 vPostgres backup routine

I would like to save a bourne shell script in /etc/cron.* on vCenter server virtual appliance 5.5 to backup the vpostgres (VMware vCenter postgresql database).
VMware knowledge base article 2034505 recommend stopping vpxd service before backing up.
I suppose to prevent backing up the database in an inconsistent state (while vcenter operations are running).
However the official PostgreSQL documentation precises :
<<3.Perform the backup, using any convenient file-system-backup tool such as tar or cpio (not pg_dump or pg_dumpall). It is neither necessary nor desirable to stop normal operation of the database while you do this.>>
My questions are:
Do I need to stop VMWare Composer and vpxd services prior to backing up the DB ?
If not can I use cpio to back it up without stopping the services ? how ?
PostgreSQL or VMware experts answers preferred please.
You may notice that this script does not stop VPXD services for backing up the database. It is because the official PostgreSQL documentation precises : “pg_dump is a utility for backing up a PostgreSQL database. It makes consistent backups even if the database is being used concurrently“.
https://web.archive.org/web/20160122054619/http://bidabe.zapto.org/?p=360

Recover PostgreSql database 9.1 with Mac

I work with PostgreSql and PgAdmin, and I have had an accident that drives to format my Mac, here I have two options, recover all system via TimeMahine or install all from zero.
I have chosen install from zero, but I need to recover the old PostgreSql database, now I’m installing all again, pgAdmin… etc, but I don’t have any backup of my old database, I have the old PostgreSql database system files (thanks to TimeMachine),
How can I recover the old database to the new one?
I tried to do this, from http://www.postgresql.org/docs/8.1/static/backup-file.html
tar -cf backup.tar /usr/local/pgsql/data
the problem is that the data files are (I think) in /Library/PostgreSQL/9.1/data and the folder is encrypted or hidden ¿?
and I can't execute tar command this is what happens:
tar -cf backup.tar "/Volumes/backup/Backups.backupdb/MacBook, MacBook Pro de Albert/2014-04-30-112220/Macintosh HD/Library/PostgreSQL/9.1/data"
I get this error:
tar: /Volumes/backup/Backups.backupdb/MacBook, MacBook Pro de Albert/2014-04-30-112220/Macintosh HD/Library/PostgreSQL/9.1/data: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors.
Another option was to copy the TimeMachine folder /9.1/ beside the new 9.3 and try this:
How to restore a file system level copy of a PostgreSQL database (not dump) to a different PC
but when executing pg_dump asked me a pasword I didn't had.
The solution for dummies: Uninstall pgAdmin 9.3, and install pgAdmin 9.1, here detects the folder 9.1 and tell me It was going to use it ¡perfect! it is exactly what I need.
Now I can keep 9.1 or upgrade to 9.3