Skip to content

Instantly share code, notes, and snippets.

@geo-stanciu
Last active April 12, 2018 20:11
Show Gist options
  • Save geo-stanciu/e36e1473d1bc6cb95977ce9526cbea49 to your computer and use it in GitHub Desktop.
Save geo-stanciu/e36e1473d1bc6cb95977ce9526cbea49 to your computer and use it in GitHub Desktop.
cd F:\PostgreSQL\9.6\data
psql -U postgres -d devel -W -c "SELECT pg_start_backup('BK 20161120');";
-- in cmd (node the last dot in command)
"C:\Program Files\Java\jdk1.8.0_74\bin\jar.exe" cvf F:/backup/data_20161118.zip -C "F:/PostgreSQL/9.6/data" .
-- in powershell (node the first ampersand and the last dot in command)
& 'C:\Program Files\Java\jdk1.8.0_74\bin\jar.exe' cvf F:/backup/data_20161118.zip -C "F:/PostgreSQL/9.6/data" .
psql -U postgres -d devel -W -c "SELECT pg_xlogfile_name(pg_stop_backup());"
-- determine last backp that you want to keep
dir F:/backup/archive
pg_archivecleanup -d F:/backup/archive 000000010000000000000015.00000028.backup
----------------------------------------------------------------------------------------------------------------------
# create .pgpass file and put 0600 mode on it
#hostname:port:database:username:password
4 localhost:5432:*:postgres:password
pg_basebackup -D /home/geo/backup/devel/20170822 \
-F t \
-r 20M \
-R \
-x \
-z \
-l "BK 20170822 base" \
-v \
-h localhost \
-p 5432 \
-U postgres
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
transaction log start point: 0/C000028 on timeline 1
transaction log end point: 0/C0000F8
pg_basebackup: base backup completed
-------------------------------------------------
# take end point from the output
psql -U geo -d devel -c "SELECT file_name from pg_xlogfile_name_offset('0/C0000F8');"
from pg_xlogfile_name_offset('0/C0000F8');"
file_name
--------------------------
00000001000000000000000C
(1 row)
-------------------------------------------------
pg_archivecleanup -d /home/geo/backup/devel/archivedir 00000001000000000000000C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment