1) barman version: 1.5.1-1.pgdg14.04+1 all Backup and Recovery Manager for PostgreSQL
2) we sync the local Barma catalog into S3 this way to preserve files dates: s3cmd sync -p /barman/localhost s3://${BUCKETNAME}/barman/
3) To get back the catalog into another AWS machine and be able perform the barman recover:
3.1) Get files from S3 where $2 is the last base backup subfolder name, for example 20151209T130715 . In the scripts, we are only getting the files form S3 older than the last selected basebackup
#!/bin/bashset -x # To debug the scriptset -e # Enables checking of all commands. To execute it on production.# Usage: get last barman backups from S3 to local -> getbarmanlastbackupinfo.sh "BUCKETNAME" "last backup subfolder in S3://bucketname/barman/localhost/base/20151125T093644"# for example getbarmanlastbackupinfo.sh "BUCKETNAME/barman/" "20151125T093644"## Check this link inspiration http://shout.setfive.com/2011/12/05/deleting-files-older-than-specified-time-with-s3cmd-and-bash/if [[ $2 ]]thens3cmd get -p --force s3://$1/localhost/base/$2/backup.info /tmp/begintime=`grep begin_time /tmp/backup.info | cut -d'=' -f2 | cut -d':' -f1-2`s3cmd --recursive ls s3://$1 | while read -r line;docreateDate=`echo $line|awk {'print $1" "$2'}`createDate=`date -d"$createDate" +%s`#olderThan=`date -d"-$2" +%s`#olderThan=$2olderThan=`date -d"$begintime" +%s`if [[ $createDate -ge $olderThan ]]thenfileName=`echo $line|awk {'print $4'}`echo $fileNameif [[ $fileName != "" ]]thenlocalname=`echo "$fileName" | cut -d'/' -f5-20`s3cmd sync -p "$fileName" /barman/$localnamefifidone;elseecho 'Usage: getbarmanlastbackupinfo.sh "BUCKETNAME/barman/" "last backup subfolder name YYYYMMDDTHH24MMSS"'echo 'see last backup subfolder name in "s3://BUCKETNAME/barman/localhost/base/LASTBACKUP/" "foldername YYYYMMDDTHH24MMSS"'echo "EXIT CODE 1"fi
3.2) Do the Barman recover (the postgresql database must be down)
Comment in postgresql.conf
#archive_mode = on
barman rebuild-xlogdb localhost <-- it is not even necessary
barman recover --remote-ssh-command="ssh postgres@localhost" --target-time "2015-12-09 14:52:59" localhost 20151209T130715 /var/lib/postgresql/9.3/main
Starting remote restore for server localhost using backup 20151209T130715Destination directory: /var/lib/postgresql/9.3/mainDoing PITR. Recovery target time: '2015-12-09 14:52:59'Copying the base backup.Copying required WAL segments.Generating recovery.conf**** EXCEPTION: unable to create the archive_status directory '/var/lib/postgresql/9.3/main/pg_xlog/archive_status': mkdir execution failed***
3.3) With postgres user:Recovery after copyng from S3, it is mandatory to create these directories:cd /var/lib/postgresql/9.3chmod 700 maincd /var/lib/postgresql/9.3/mainmkdir pg_tblspcmkdir pg_xlogmkdir pg_xlog/archive_statusmkdir pg_statmkdir pg_twophase
3.4) service postgresql start
how should i solve it?
I restore it on another server.