You've already forked pg_probackup
							
							
				mirror of
				https://github.com/postgrespro/pg_probackup.git
				synced 2025-10-31 00:17:52 +02:00 
			
		
		
		
	Rename project to pg_probackup.
This commit is contained in:
		
							
								
								
									
										8
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								Makefile
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| PROGRAM = pg_arman | ||||
| PROGRAM = pg_probackup | ||||
| OBJS = backup.o \ | ||||
| 	catalog.o \ | ||||
| 	data.o \ | ||||
| @@ -7,7 +7,7 @@ OBJS = backup.o \ | ||||
| 	fetch.o \ | ||||
| 	init.o \ | ||||
| 	parray.o \ | ||||
| 	pg_arman.o \ | ||||
| 	pg_probackup.o \ | ||||
| 	restore.o \ | ||||
| 	show.o \ | ||||
| 	status.o \ | ||||
| @@ -25,7 +25,7 @@ EXTRA_CLEAN = datapagemap.c datapagemap.h xlogreader.c receivelog.c receivelog.h | ||||
|  | ||||
| REGRESS = init option show delete backup restore | ||||
|  | ||||
| all: checksrcdir datapagemap.h logging.h receivelog.h streamutil.h pg_arman | ||||
| all: checksrcdir datapagemap.h logging.h receivelog.h streamutil.h pg_probackup | ||||
|  | ||||
| MAKE_GLOBAL="../../src/Makefile.global" | ||||
| TEST_GLOBAL:=$(shell test -e ../../src/Makefile.global) | ||||
| @@ -45,7 +45,7 @@ endif | ||||
| else | ||||
| #TODO: fix me | ||||
| REGRESS = | ||||
| subdir=contrib/pg_arman | ||||
| subdir=contrib/pg_probackup | ||||
| top_builddir=../.. | ||||
| include $(top_builddir)/src/Makefile.global | ||||
| include $(top_srcdir)/contrib/contrib-global.mk | ||||
|   | ||||
							
								
								
									
										51
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,10 +1,7 @@ | ||||
| pg_arman fork from Postgres Professional | ||||
| pg_probackup fork of pg_arman by Postgres Professional | ||||
| ======================================== | ||||
|  | ||||
| This repository contains fork of pg_arman by Postgres Professional with | ||||
| block level incremental backup support. | ||||
|  | ||||
| pg_arman is a backup and recovery manager for PostgreSQL servers able to do | ||||
| pg_probackup is a backup and recovery manager for PostgreSQL servers able to do | ||||
| differential and full backup as well as restore a cluster to a | ||||
| state defined by a given recovery target. It is designed to perform | ||||
| periodic backups of an existing PostgreSQL server, combined with WAL | ||||
| @@ -28,13 +25,13 @@ Download | ||||
| -------- | ||||
|  | ||||
| The latest version of this software can be found on the project website at | ||||
| https://github.com/postgrespro/pg_arman.  Original fork of pg_arman can be | ||||
| https://github.com/postgrespro/pg_probackup.  Original fork of pg_probackup can be | ||||
| found at https://github.com/michaelpq/pg_arman. | ||||
|  | ||||
| Installation | ||||
| ------------ | ||||
|  | ||||
| Compiling pg_arman requires a PostgreSQL installation to be in place | ||||
| Compiling pg_probackup requires a PostgreSQL installation to be in place | ||||
| as well as a raw source tree. Pass the path to the PostgreSQL source tree | ||||
| to make, in the top_srcdir variable: | ||||
|  | ||||
| @@ -42,23 +39,23 @@ to make, in the top_srcdir variable: | ||||
|  | ||||
| In addition, you must have pg_config in $PATH. | ||||
|  | ||||
| The current version of pg_arman is compatible with PostgreSQL 9.5 and | ||||
| The current version of pg_probackup is compatible with PostgreSQL 9.5 and | ||||
| upper versions. | ||||
|  | ||||
| Platforms | ||||
| --------- | ||||
|  | ||||
| pg_arman has been tested on Linux and Unix-based platforms. | ||||
| pg_probackup has been tested on Linux and Unix-based platforms. | ||||
|  | ||||
| Documentation | ||||
| ------------- | ||||
|  | ||||
| All the documentation you can find [here](doc/pg_arman.md). | ||||
| All the documentation you can find [here](doc/pg_probackup.md). | ||||
|  | ||||
| Regression tests | ||||
| ---------------- | ||||
|  | ||||
| The test suite of pg_arman is available in the code tree and can be | ||||
| The test suite of pg_probackup is available in the code tree and can be | ||||
| launched in a way similar to common PostgreSQL extensions and modules: | ||||
|  | ||||
|     make installcheck | ||||
| @@ -85,7 +82,7 @@ of these approach is requirement to have WAL archive. | ||||
| some overhead to PostgreSQL performance.  On our experiments it appears to be | ||||
| less than 3%. | ||||
|  | ||||
| These two approaches were implemented in this fork of pg_arman.  The second | ||||
| These two approaches were implemented in this fork of pg_probackup.  The second | ||||
| approach requires [patch for PostgreSQL 9.5](https://gist.github.com/stalkerg/44703dbcbac1da08f448b7e6966646c0) or | ||||
| [patch for PostgreSQL 10](https://gist.github.com/stalkerg/ab833d94e2f64df241f1835651e06e4b). | ||||
|  | ||||
| @@ -101,29 +98,29 @@ You need to enable WAL archive by adding following lines to postgresql.conf: | ||||
|  | ||||
| ``` | ||||
| wal_level = archive | ||||
| archive_command = 'test ! -f /home/postgres/backup/arman/wal/%f && cp %p /home/postgres/backup/arman/wal/%f' | ||||
| archive_command = 'test ! -f /home/postgres/backup/wal/%f && cp %p /home/postgres/backup/wal/%f' | ||||
| ``` | ||||
|  | ||||
| Example backup (assuming PostgreSQL is running): | ||||
| ```bash | ||||
| # Init pg_aramn backup folder | ||||
| pg_arman init -B /home/postgres/backup/pgarman | ||||
| pg_probackup init -B /home/postgres/backup | ||||
| # Make full backup with 2 thread and verbose mode. | ||||
| pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b full -v -j 2 | ||||
| pg_probackup backup -B /home/postgres/backup -D /home/postgres/pgdata -b full -v -j 2 | ||||
| # Show backups information | ||||
| pg_arman show -B /home/postgres/backup/pgarman | ||||
| pg_probackup show -B /home/postgres/backup | ||||
|  | ||||
| # Now you can insert or update some data in your database | ||||
|  | ||||
| # Then start the incremental backup. | ||||
| pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b page -v -j 2 | ||||
| pg_probackup backup -B /home/postgres/backup -D /home/postgres/pgdata -b page -v -j 2 | ||||
| # You should see that increment is really small | ||||
| pg_arman show -B /home/postgres/backup/pgarman | ||||
| pg_probackup show -B /home/postgres/backup | ||||
| ``` | ||||
|  | ||||
| For restore after remove your pgdata you can use: | ||||
| ``` | ||||
| pg_arman restore -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -j 4 --verbose | ||||
| pg_probackup restore -B /home/postgres/backup -D /home/postgres/pgdata -j 4 --verbose | ||||
| ``` | ||||
|  | ||||
| ### Retrieving changed blocks from ptrack | ||||
| @@ -134,33 +131,33 @@ The advantage of this approach is that you don't have to save WAL archive.  You | ||||
| ptrack_enable = on | ||||
| ``` | ||||
|  | ||||
| Also, some WALs still need to be fetched in order to get consistent backup.  pg_arman can fetch them trough the streaming replication protocol.  Thus, you also need to [enable streaming replication connection](https://wiki.postgresql.org/wiki/Streaming_Replication). | ||||
| Also, some WALs still need to be fetched in order to get consistent backup.  pg_probackup can fetch them trough the streaming replication protocol.  Thus, you also need to [enable streaming replication connection](https://wiki.postgresql.org/wiki/Streaming_Replication). | ||||
|  | ||||
| Example backup (assuming PostgreSQL is running): | ||||
| ```bash | ||||
| # Init pg_aramn backup folder | ||||
| pg_arman init -B /home/postgres/backup/pgarman | ||||
| pg_probackup init -B /home/postgres/backup | ||||
| # Make full backup with 2 thread and verbose mode. | ||||
| pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b full -v -j 2 --stream | ||||
| pg_probackup backup -B /home/postgres/backup -D /home/postgres/pgdata -b full -v -j 2 --stream | ||||
| # Show backups information | ||||
| pg_arman show -B /home/postgres/backup/pgarman | ||||
| pg_probackup show -B /home/postgres/backup | ||||
|  | ||||
| # Now you can insert or update some data in your database | ||||
|  | ||||
| # Then start the incremental backup. | ||||
| pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b ptrack -v -j 2 --stream | ||||
| pg_probackup backup -B /home/postgres/backup -D /home/postgres/pgdata -b ptrack -v -j 2 --stream | ||||
| # You should see that increment is really small | ||||
| pg_arman show -B /home/postgres/backup/pgarman | ||||
| pg_probackup show -B /home/postgres/backup | ||||
| ``` | ||||
|  | ||||
| For restore after remove your pgdata you can use: | ||||
| ``` | ||||
| pg_arman restore -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -j 4 --verbose --stream | ||||
| pg_probackup restore -B /home/postgres/backup -D /home/postgres/pgdata -j 4 --verbose --stream | ||||
| ``` | ||||
|  | ||||
| License | ||||
| ------- | ||||
|  | ||||
| pg_arman can be distributed under the PostgreSQL license. See COPYRIGHT | ||||
| pg_probackup can be distributed under the PostgreSQL license. See COPYRIGHT | ||||
| file for more information. pg_arman is a fork of the existing project | ||||
| pg_rman, initially created and maintained by NTT and Itagaki Takahiro. | ||||
|   | ||||
							
								
								
									
										8
									
								
								backup.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								backup.c
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| @@ -35,7 +35,7 @@ static int server_version = 0; | ||||
| static bool	in_backup = false;						/* TODO: more robust logic */ | ||||
| static int	standby_message_timeout = 10 * 1000;	/* 10 sec = default */ | ||||
| static XLogRecPtr stop_backup_lsn = InvalidXLogRecPtr; | ||||
| const char *progname = "pg_arman"; | ||||
| const char *progname = "pg_probackup"; | ||||
|  | ||||
| /* list of files contained in backup */ | ||||
| parray	*backup_files_list; | ||||
| @@ -161,7 +161,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt) | ||||
|  | ||||
| 	/* notify start of backup to PostgreSQL server */ | ||||
| 	time2iso(label, lengthof(label), current.start_time); | ||||
| 	strncat(label, " with pg_arman", lengthof(label)); | ||||
| 	strncat(label, " with pg_probackup", lengthof(label)); | ||||
| 	pg_start_backup(label, smooth_checkpoint, ¤t); | ||||
|  | ||||
| 	/* start stream replication */ | ||||
| @@ -476,7 +476,7 @@ do_backup(pgBackupOption bkupopt) | ||||
| 		elog(ERROR, "cannot lock backup catalog"); | ||||
| 	else if (ret == 1) | ||||
| 		elog(ERROR, | ||||
| 			"another pg_arman is running, skipping this backup"); | ||||
| 			"another pg_probackup is running, skipping this backup"); | ||||
|  | ||||
| 	/* initialize backup result */ | ||||
| 	current.status = BACKUP_STATUS_RUNNING; | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <dirent.h> | ||||
| #include <fcntl.h> | ||||
| @@ -28,7 +28,7 @@ static pgBackup *catalog_read_ini(const char *path); | ||||
| static int lock_fd = -1; | ||||
|  | ||||
| /* | ||||
|  * Lock of the catalog with pg_arman.ini file and return 0. | ||||
|  * Lock of the catalog with pg_probackup.conf file and return 0. | ||||
|  * If the lock is held by another one, return 1 immediately. | ||||
|  */ | ||||
| int | ||||
|   | ||||
							
								
								
									
										2
									
								
								data.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								data.c
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <unistd.h> | ||||
| #include <time.h> | ||||
|   | ||||
							
								
								
									
										6
									
								
								delete.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								delete.c
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <dirent.h> | ||||
| #include <unistd.h> | ||||
| @@ -34,7 +34,7 @@ do_delete(time_t backup_id) | ||||
| 		elog(ERROR, "can't lock backup catalog."); | ||||
| 	else if (ret == 1) | ||||
| 		elog(ERROR, | ||||
| 			"another pg_arman is running, stop delete."); | ||||
| 			"another pg_probackup is running, stop delete."); | ||||
|  | ||||
| 	/* Get complete list of backups */ | ||||
| 	backup_list = catalog_get_backup_list(0); | ||||
| @@ -109,7 +109,7 @@ int do_deletewal(time_t backup_id, bool strict) | ||||
| 		elog(ERROR, "can't lock backup catalog."); | ||||
| 	else if (ret == 1) | ||||
| 		elog(ERROR, | ||||
| 			"another pg_arman is running, stop delete."); | ||||
| 			"another pg_probackup is running, stop delete."); | ||||
|  | ||||
| 	backup_list = catalog_get_backup_list(0); | ||||
| 	for (i = 0; i < parray_num(backup_list); i++) | ||||
|   | ||||
							
								
								
									
										2
									
								
								dir.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								dir.c
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <libgen.h> | ||||
| #include <unistd.h> | ||||
|   | ||||
							
								
								
									
										414
									
								
								doc/pg_arman.md
									
									
									
									
									
								
							
							
						
						
									
										414
									
								
								doc/pg_arman.md
									
									
									
									
									
								
							| @@ -1,414 +0,0 @@ | ||||
| # pg_arman(1)  | ||||
|  | ||||
| ## NAME  | ||||
|  | ||||
| pg_arman - Backup and recovery manager for PostgreSQL | ||||
|  | ||||
| ## SYNOPSIS  | ||||
| ``` | ||||
| pg_arman [ OPTIONS ] | ||||
|     { init | | ||||
|       backup | | ||||
|       restore | | ||||
| 	  show [ ID] | | ||||
| 	  validate [ ID ] | | ||||
| 	  delete ID } | ||||
| ``` | ||||
|  | ||||
| ID is the base36 id from start time of the target backup. | ||||
|  | ||||
| ## DESCRIPTION  | ||||
|  | ||||
| pg_arman is a utility program to backup and restore PostgreSQL database. | ||||
|  | ||||
| It proposes the following features: | ||||
|  | ||||
| - Backup while database runs including tablespaces with just one | ||||
|   command | ||||
| - Recovery from backup with just one command, with customized targets | ||||
|   to facilitate the use of PITR. | ||||
| - Support for full and differential backup + ptrack differential backup | ||||
| - Management of backups with integrated catalog | ||||
|  | ||||
| ## COMMANDS  | ||||
|  | ||||
| pg_arman supports the following commands. See also **OPTIONS** for more | ||||
| details. | ||||
|  | ||||
| * **init**:   | ||||
| 	Initialize a backup catalog. | ||||
|  | ||||
| * **backup**:   | ||||
| 	Take an online backup. | ||||
|  | ||||
| * **restore**:   | ||||
| 	Perform restore. | ||||
|  | ||||
| * **show**:   | ||||
| 	Show backup history. The timeline option shows timeline of the backup and the parent's timeline for each backup. | ||||
|  | ||||
| * **validate**:   | ||||
|     Validate backup files. | ||||
|  | ||||
| * **delete**:   | ||||
| 	Delete backup files. | ||||
|  | ||||
| ### INITIALIZATION  | ||||
|  | ||||
| First, you need to create "a backup catalog" to store backup files and | ||||
| their metadata. It is recommended to setup archive_mode and archive_command | ||||
| in postgresql.conf before initializing the backup catalog. If the variables | ||||
| are initialized, pg_arman can adjust the config file to the setting. In this | ||||
| case, you have to specify the database cluster path for PostgreSQL. Please | ||||
| specify it in PGDATA environmental variable or -D/--pgdata option. | ||||
|  | ||||
| ``` | ||||
| $ pg_arman init -B /path/to/backup/ | ||||
| ``` | ||||
|  | ||||
| ### BACKUP  | ||||
|  | ||||
| Backup target can be one of the following types: | ||||
|  | ||||
| - Full backup, backup a whole database cluster. | ||||
| - Differential backup, backup only files or pages modified after the last | ||||
| verified backup. A scan of the WAL records since the last backup up to the | ||||
| LSN position of pg_start_backup is done and all the blocks touched are | ||||
| recorded and tracked as part of the backup. As the WAL segments scanned | ||||
| need to be located in the WAL archive, the last segment after pg_start_backup | ||||
| has been run needs to be forcibly switched. | ||||
| - ptrack differential backup, use bitmap ptrack file for detect changed pages. | ||||
| For use it you need set ptrack_enable option to "on". | ||||
|  | ||||
| It is recommended to verify backup files as soon as possible after backup. | ||||
| Unverified backup cannot be used in restore and in differential backups. | ||||
|  | ||||
| ### RESTORE  | ||||
|  | ||||
| PostgreSQL server should be stopped before performing a restore. If database | ||||
| cluster still exists, restore command will save unarchived transaction log | ||||
| and delete all database files. You can retry recovery until a new backup is | ||||
| taken. After restoring files, pg_arman creates recovery.conf in $PGDATA. The | ||||
| conf file contains parameters for recovery. It is as well possible to modify | ||||
| the file manually. | ||||
|  | ||||
| It is recommended to take a full backup as soon as possible after recovery | ||||
| has succeeded. | ||||
|  | ||||
| If "--timeline" is not specifed, the last checkpoint's | ||||
| TimeLineID in control file ($PGDATA/global/pg_control) will be the restore | ||||
| target. If pg_control is not present, TimeLineID in the full backup used by | ||||
| the restore will be a restore target. | ||||
|  | ||||
|  | ||||
| ### EXAMPLES  | ||||
|  | ||||
| To reduce the number of command line arguments, you can set BACKUP_PATH, | ||||
| an environment variable, to the absolute path of the backup catalog and | ||||
| write default configuration into ${BACKUP_PATH}/pg_arman.ini. | ||||
|  | ||||
| ``` | ||||
| $ cat $BACKUP_PATH/pg_arman.ini | ||||
| ARCLOG_PATH = /home/postgres/arclog | ||||
| BACKUP_MODE = FULL | ||||
| KEEP_DATA_GENERATIONS = 3 | ||||
| KEEP_DATA_DAYS = 120 | ||||
| ``` | ||||
|  | ||||
| ### TAKE A BACKUP  | ||||
|  | ||||
| This example takes a full backup of the whole database. Then, it validates | ||||
| all unvalidated backups. | ||||
| ``` | ||||
| $ pg_arman backup --backup-mode=full | ||||
| $ pg_arman validate | ||||
| ``` | ||||
|  | ||||
| ### RESTORE FROM A BACKUP  | ||||
|  | ||||
| Here are some commands to restore from a backup: | ||||
|  | ||||
| ``` | ||||
| $ pg_ctl stop -m immediate | ||||
| $ pg_arman restore | ||||
| $ pg_ctl start | ||||
| ``` | ||||
|  | ||||
| ### SHOW A BACKUP  | ||||
| ``` | ||||
| $ pg_arman show | ||||
| ========================================================================================== | ||||
| ID       Recovery time        Mode  Current TLI  Parent TLI  Time    Data   Backup   Status | ||||
| ========================================================================================== | ||||
| OFX1LH   2013-12-25 03:02:31  PAGE            1           0    0m   203kB     67MB   DONE | ||||
| OFX1KL   2013-12-25 03:02:31  PAGE            1           0    0m      0B       0B   ERROR | ||||
| OFX1KA   2013-12-25 03:02:25  FULL            1           0    0m    33MB    364MB   OK | ||||
| ``` | ||||
| The fields are: | ||||
|  | ||||
| * Start: start time of backup | ||||
| * Mode: Mode of backup: FULL (full) or PAGE (page differential) or PTRACK (differential by ptrack) | ||||
| * Current TLI: current timeline of backup | ||||
| * Parent TLI: parent timeline of backup | ||||
| * Time: total time necessary to take this backup | ||||
| * Data: size of data files | ||||
| * Log: size of read server log files | ||||
| * Backup: size of backup (= written size) | ||||
| * Status: status of backup. Possible values are: | ||||
| 	* OK : backup is done and validated. | ||||
| 	* DONE : backup is done, but not validated yet. | ||||
| 	* RUNNING : backup is running | ||||
| 	* DELETING : backup is being deleted. | ||||
| 	* DELETED : backup has been deleted. | ||||
| 	* ERROR : backup is unavailable because some errors occur during backup. | ||||
| 	* CORRUPT : backup is unavailable because it is broken. | ||||
|  | ||||
| When a ID is specified, more details about a backup is retrieved: | ||||
|  | ||||
| ``` | ||||
| $ pg_arman show OFX1LH | ||||
| # configuration | ||||
| BACKUP_MODE=FULL | ||||
| # result | ||||
| TIMELINEID=1 | ||||
| START_LSN=0/08000020 | ||||
| STOP_LSN=0/080000a0 | ||||
| START_TIME='2011-11-27 19:15:45' | ||||
| END_TIME='2011-11-27 19:19:02' | ||||
| RECOVERY_XID=1759 | ||||
| RECOVERY_TIME='2011-11-27 19:15:53' | ||||
| DATA_BYTES=25420184 | ||||
| BLOCK_SIZE=8192 | ||||
| XLOG_BLOCK_SIZE=8192 | ||||
| STATUS=OK | ||||
| ``` | ||||
|  | ||||
| You can check the "RECOVERY_XID" and "RECOVERY_TIME" which are used for | ||||
| restore option "--xid", "--time". | ||||
|  | ||||
| The delete command deletes backup files not required by recovery after | ||||
| the specified ID. This command also cleans up in the WAL archive the | ||||
| WAL segments that are no longer needed to restore from the remaining | ||||
| backups. | ||||
|  | ||||
| ### OPTIONS  | ||||
|  | ||||
| pg_arman accepts the following command line parameters. Some of them can | ||||
| be also specified as environment variables. See also *PARAMETERS* for the | ||||
| details. | ||||
|  | ||||
| ### COMMON OPTIONS  | ||||
| As a general rule, paths for data location need to be specified as | ||||
| absolute paths; relative paths are not allowed. | ||||
|  | ||||
| **-D** PATH / **--pgdata**=PATH:   | ||||
|     The absolute path of database cluster. Required on backup and | ||||
|     restore. | ||||
|  | ||||
| **-A** PATH / **--arclog-path**=PATH:   | ||||
|     The absolute path of archive WAL directory. Required for restore | ||||
|     and show command. | ||||
|  | ||||
| **-B** PATH / **--backup-path**=PATH:   | ||||
|     The absolute path of backup catalog. This option is mandatory. | ||||
|  | ||||
| **-c** / **--check**:   | ||||
|     If specifed, pg_arman doesn't perform actual jobs but only checks | ||||
|     parameters and required resources. The option is typically used with | ||||
|     --verbose option to verify the operation. | ||||
|  | ||||
| ### BACKUP OPTIONS | ||||
|  | ||||
| **-b** BACKUPMODE / **--backup-mode**=BACKUPMODE:   | ||||
|     Specify backup target files. Available options are: "full", | ||||
|     "page", "ptrack". | ||||
|  | ||||
| **-C** / **--smooth-checkpoint**:   | ||||
|     Checkpoint is performed on every backups. If the option is specified, | ||||
|     do smooth checkpoint then. See also the second argument for | ||||
|     pg_start_backup(). | ||||
|  | ||||
| **--validate**:   | ||||
|     Validate a backup just after taking it. Other backups taken | ||||
|     previously are ignored. | ||||
|  | ||||
| **--keep-data-generations**=NUMBER / **--keep-data-days**=DAYS:   | ||||
|     Specify how long backuped data files will be kept. | ||||
|     --keep-data-generations means number of backup generations. | ||||
|     --keep-data-days means days to be kept. | ||||
|     Only files exceeded one of those settings are deleted. | ||||
|  | ||||
| **-j**=NUMBER / **--threads**=NUMBER:   | ||||
|     Number of threads for backup. | ||||
|  | ||||
| **--stream**:   | ||||
|     Enable stream replication for save WAL during backup process. | ||||
|  | ||||
|  | ||||
| ### RESTORE OPTIONS  | ||||
|  | ||||
| The parameters whose name start are started with --recovery refer to | ||||
| the same parameters as the ones in recovery.confin recovery.conf. | ||||
|  | ||||
| **--timeline**=_TIMELINE_: | ||||
|     Specifies recovering into a particular timeline. If not specified, | ||||
|     the current timeline is used. | ||||
|  | ||||
| **--time**=TIMESTAMP: | ||||
|     This parameter specifies the timestamp up to which recovery will | ||||
|     proceed. | ||||
|  | ||||
| **--xid**=XID: | ||||
|     This parameter specifies the transaction ID up to which recovery | ||||
|     will proceed. | ||||
|  | ||||
| **--inclusive**: | ||||
|     Specifies whether server pauses when recovery target is reached. | ||||
|  | ||||
| **-j**=NUMBER / **--threads**=NUMBER:  | ||||
|     Number of threads for restore.  | ||||
|  | ||||
| **--stream**:  | ||||
|     Restore without recovery.conf and use pg_xlog WALs. Before you need  | ||||
|     backup with **--stream** option. This option will disable all **--recovery-** | ||||
| 	options. | ||||
|  | ||||
| ### CATALOG OPTIONS | ||||
|  | ||||
| **-a** / **--show-all**:   | ||||
|     Show all existing backups, including the deleted ones. | ||||
|  | ||||
| ### CONNECTION OPTIONS  | ||||
| Parameters to connect PostgreSQL server. | ||||
|  | ||||
| **-d** DBNAME / **--dbname**=DBNAME:   | ||||
|     The database name to execute pg_start_backup() and pg_stop_backup(). | ||||
|  | ||||
| **-h** HOSTNAME / **--host**=HOSTNAME:   | ||||
|     Specifies the host name of the machine on which the server is running. | ||||
|     If the value begins with a slash, it is used as the directory for the | ||||
|     Unix domain socket. | ||||
|  | ||||
| **-p** PORT / **--port**=PORT:   | ||||
|     Specifies the TCP port or local Unix domain socket file extension on | ||||
|     which the server is listening for connections. | ||||
|  | ||||
| **-U** USERNAME / **--username**=USERNAME:   | ||||
|     User name to connect as. | ||||
|  | ||||
| **-w** / **--no-password**:   | ||||
|     Never issue a password prompt. If the server requires password | ||||
|     authentication and a password is not available by other means such as | ||||
|     a .pgpass file, the connection attempt will fail. This option can be | ||||
|     useful in batch jobs and scripts where no user is present to enter a | ||||
|     password. | ||||
|  | ||||
| **-W** / **--password**:   | ||||
|     Force pg_arman to prompt for a password before connecting to a database. | ||||
|     This option is never essential, since pg_arman will automatically | ||||
|     prompt for a password if the server demands password authentication. | ||||
|     However, pg_arman will waste a connection attempt in order to find out | ||||
|     if the server wants a password. In some cases it is worth typing -W | ||||
|     to avoid the extra connection attempt. | ||||
|  | ||||
| ### DELETE OPTIONS | ||||
|  | ||||
| **--wal**: | ||||
| 	Remove unnecessary wal archives also. | ||||
|  | ||||
| ### GLOBAL OPTIONS  | ||||
|  | ||||
| **--help**:   | ||||
|     Print help, then exit. | ||||
|  | ||||
| **-V** / **--version**:   | ||||
|     Print version information, then exit. | ||||
|  | ||||
| **-v** / **--verbose**:   | ||||
|     If specified, pg_arman works in verbose mode. | ||||
|  | ||||
| ## PARAMETERS  | ||||
|  | ||||
| Some of parameters can be specified as command line arguments, environment | ||||
| variables or in configuration file as follows: | ||||
| ``` | ||||
| Short   Long                    Env                     File | ||||
| -h      --host                  PGHOST                  No | ||||
| -p      --port                  PGPORT                  No | ||||
| -d      --dbname                PGDATABASE              No | ||||
| -U      --username              PGUSER                  No | ||||
|                                 PGPASSWORD              No | ||||
| -w      --password                                      No | ||||
| -W      --no-password                                   No | ||||
| -D      --pgdata                PGDATA                  Yes | ||||
| -B      --backup-path           BACKUP_PATH             Yes | ||||
| -A      --arclog-path           ARCLOG_PATH             Yes | ||||
| -b      --backup-mode           BACKUP_MODE             Yes | ||||
| -C      --smooth-checkpoint     SMOOTH_CHECKPOINT       Yes | ||||
|         --validate              VALIDATE                Yes | ||||
|         --keep-data-generations KEEP_DATA_GENERATIONS   Yes | ||||
|         --keep-data-days        KEEP_DATA_DAYS          Yes | ||||
| 		--timeline RECOVERY_TARGET_TIMELINE Yes | ||||
| 		--xid   RECOVERY_TARGET_XID     Yes | ||||
| 		--time  RECOVERY_TARGET_TIME    Yes | ||||
| 		--inclusive RECOVERY_TARGET_INCLUSIVE Yes | ||||
| ``` | ||||
|  | ||||
| Variable names in configuration file are the same as long names or names | ||||
| of environment variables. The password can not be specified in command | ||||
| line and configuration file for security reason. | ||||
|  | ||||
| This utility, like most other PostgreSQL utilities, also uses the | ||||
| environment variables supported by libpq (see Environment Variables). | ||||
|  | ||||
| ## RESTRICTIONS | ||||
|  | ||||
| pg_arman has the following restrictions. | ||||
|  | ||||
| - Requires to read database cluster directory and write backup catalog | ||||
|   directory. It is usually necessary to mount the disk where backup | ||||
|   catalog is placed with NFS or related from database server. | ||||
| - Major versions of pg_arman and server should match. | ||||
| - Block sizes of pg_arman and server should match. | ||||
| - If there are some unreadable files/directories in data folder of server | ||||
|   WAL directory or archived WAL directory, the backup or restore will fail | ||||
|   depending on the backup mode selected. | ||||
|  | ||||
| ## DETAILS | ||||
|  | ||||
| ### RECOVERY TO POINT-IN-TIME  | ||||
| pg_arman can recover to point-in-time if timeline, transaction ID, or | ||||
| timestamp is specified in recovery.conf. xlogdump is a contrib module of | ||||
| PostgreSQL core that allows checking in the content of WAL files and | ||||
| determine when to recover. This might help. | ||||
|  | ||||
| ### CONFIGURATION FILE  | ||||
| Setting parameters in configuration file is done as "name=value". Quotes | ||||
| are required if the value contains whitespaces. Comments should start with | ||||
| "#" and are automatically ignored. Whitespaces and tabs are ignored | ||||
| excluding values. | ||||
|  | ||||
| ### RESTRICTIONS | ||||
| * pg_arman is aimed at working with PostgreSQL 9.5 and newer versions. | ||||
| * For ptrack feature you need special version of Postgres and set wal_level to | ||||
| archive or hot_standby and ptrack_enable. | ||||
| * For stream feature you need configure streaming replication in your postgres.  | ||||
|  | ||||
| ### EXIT CODE  | ||||
| pg_arman returns exit codes for each error status. | ||||
|  | ||||
| ``` | ||||
| Code    Name                    Description | ||||
| 0       SUCCESS                 Operation succeeded. | ||||
| 1       ERROR                   Generic error | ||||
| 2       FATAL                   Exit because of repeated errors | ||||
| 3       PANIC                   Unknown critical condition | ||||
| ``` | ||||
|  | ||||
| ## AUTHOR ## | ||||
| pg_arman is a fork of pg_arman that was originally written by NTT, now | ||||
| developed and maintained by Michael Paquier. | ||||
| Threads, WAL diff, ptrack diff, stream WAL and some other features developed by | ||||
| Yury Zhuravlev aka stalkerg from PostgresPro.  | ||||
|  | ||||
| Please report bug reports at <https://github.com/postgrespro/pg_arman/issues>. | ||||
| @@ -4,21 +4,21 @@ | ||||
| 0 | ||||
| results/init/backup/ | ||||
| results/init/backup/backups/ | ||||
| results/init/backup/pg_arman.ini | ||||
| results/init/backup/pg_probackup.conf | ||||
| results/init/backup/wal/ | ||||
| ###### INIT COMMAND TEST-0002 ###### | ||||
| ###### success with archive_command and log_directory ###### | ||||
| 0 | ||||
| results/init/backup/ | ||||
| results/init/backup/backups/ | ||||
| results/init/backup/pg_arman.ini | ||||
| results/init/backup/pg_probackup.conf | ||||
| results/init/backup/wal/ | ||||
| ###### INIT COMMAND TEST-0003 ###### | ||||
| ###### success without archive_command ###### | ||||
| 0 | ||||
| results/init/backup/ | ||||
| results/init/backup/backups/ | ||||
| results/init/backup/pg_arman.ini | ||||
| results/init/backup/pg_probackup.conf | ||||
| results/init/backup/wal/ | ||||
| ###### INIT COMMAND TEST-0004 ###### | ||||
| ###### failure with backup catalog already existed ###### | ||||
|   | ||||
| @@ -1,16 +1,16 @@ | ||||
| \! bash sql/option.sh | ||||
| ###### COMMAND OPTION TEST-0001 ###### | ||||
| ###### help option ###### | ||||
| pg_arman manage backup/recovery of PostgreSQL database. | ||||
| pg_probackup manage backup/recovery of PostgreSQL database. | ||||
|  | ||||
| Usage: | ||||
|   pg_arman OPTION init | ||||
|   pg_arman OPTION backup | ||||
|   pg_arman OPTION restore | ||||
|   pg_arman OPTION show [ID] | ||||
|   pg_arman OPTION validate [ID] | ||||
|   pg_arman OPTION delete ID | ||||
|   pg_arman OPTION delwal [ID] | ||||
|   pg_probackup OPTION init | ||||
|   pg_probackup OPTION backup | ||||
|   pg_probackup OPTION restore | ||||
|   pg_probackup OPTION show [ID] | ||||
|   pg_probackup OPTION validate [ID] | ||||
|   pg_probackup OPTION delete ID | ||||
|   pg_probackup OPTION delwal [ID] | ||||
|  | ||||
| Common Options: | ||||
|   -D, --pgdata=PATH         location of the database storage area | ||||
| @@ -51,13 +51,13 @@ Generic options: | ||||
|   --help                    show this help, then exit | ||||
|   --version                 output version information, then exit | ||||
|  | ||||
| Read the website for details. <https://github.com/stalkerg/pg_arman> | ||||
| Report bugs to <https://github.com/stalkerg/pg_arman/issues>. | ||||
| Read the website for details. <https://github.com/postgrespro/pg_probackup> | ||||
| Report bugs to <https://github.com/postgrespro/pg_probackup/issues>. | ||||
| 1 | ||||
|  | ||||
| ###### COMMAND OPTION TEST-0002 ###### | ||||
| ###### version option ###### | ||||
| pg_arman 0.1 | ||||
| pg_probackup 1.0 | ||||
| 1 | ||||
|  | ||||
| ###### COMMAND OPTION TEST-0003 ###### | ||||
| @@ -81,33 +81,33 @@ ERROR: required backup ID not specified | ||||
| 1 | ||||
|  | ||||
| ###### COMMAND OPTION TEST-0008 ###### | ||||
| ###### syntax error in pg_arman.ini ###### | ||||
| ###### syntax error in pg_probackup.conf ###### | ||||
| WARNING: syntax error in " = INFINITE" | ||||
| ERROR: Required parameter not specified: BACKUP_MODE (-b, --backup-mode) | ||||
| 1 | ||||
|  | ||||
| ###### COMMAND OPTION TEST-0009 ###### | ||||
| ###### invalid value in pg_arman.ini ###### | ||||
| ###### invalid value in pg_probackup.conf ###### | ||||
| ERROR: invalid backup-mode "" | ||||
| 1 | ||||
|  | ||||
| ###### COMMAND OPTION TEST-0010 ###### | ||||
| ###### invalid value in pg_arman.ini ###### | ||||
| ###### invalid value in pg_probackup.conf ###### | ||||
| ERROR: invalid option "KEEP_DATA_GENERATIONS" | ||||
| 1 | ||||
|  | ||||
| ###### COMMAND OPTION TEST-0011 ###### | ||||
| ###### invalid value in pg_arman.ini ###### | ||||
| ###### invalid value in pg_probackup.conf ###### | ||||
| ERROR: option -C, --smooth-checkpoint should be a boolean: 'FOO' | ||||
| 1 | ||||
|  | ||||
| ###### COMMAND OPTION TEST-0012 ###### | ||||
| ###### invalid option in pg_arman.ini ###### | ||||
| ###### invalid option in pg_probackup.conf ###### | ||||
| ERROR: invalid option "TIMELINEID" | ||||
| 1 | ||||
|  | ||||
| ###### COMMAND OPTION TEST-0013 ###### | ||||
| ###### check priority of several pg_arman.ini files ###### | ||||
| ###### check priority of several pg_probackup.conf files ###### | ||||
| ERROR: invalid backup-mode "ENV_PATH" | ||||
| 1 | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								fetch.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								fetch.c
									
									
									
									
									
								
							| @@ -19,7 +19,7 @@ | ||||
| #include <unistd.h> | ||||
| #include <string.h> | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| /* | ||||
|  * Read a file into memory. The file to be read is <datadir>/<path>. | ||||
|   | ||||
							
								
								
									
										6
									
								
								init.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								init.c
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <unistd.h> | ||||
| #include <dirent.h> | ||||
| @@ -58,11 +58,11 @@ do_init(void) | ||||
| 		parse_postgresql_conf(path, &log_directory, &archive_command); | ||||
| 	} | ||||
|  | ||||
| 	/* create pg_arman.ini */ | ||||
| 	/* create pg_probackup.conf */ | ||||
| 	join_path_components(path, backup_path, PG_RMAN_INI_FILE); | ||||
| 	fp = fopen(path, "wt"); | ||||
| 	if (fp == NULL) | ||||
| 		elog(ERROR, "cannot create pg_arman.ini: %s", strerror(errno)); | ||||
| 		elog(ERROR, "cannot create pg_probackup.conf: %s", strerror(errno)); | ||||
|  | ||||
| 	join_path_components(arclog_path_dir, backup_path, "wal"); | ||||
| 	dir_create_dir(arclog_path_dir, DIR_PERMISSION); | ||||
|   | ||||
							
								
								
									
										2
									
								
								parray.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								parray.c
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| /* members of struct parray are hidden from client. */ | ||||
| struct parray | ||||
|   | ||||
| @@ -11,7 +11,7 @@ | ||||
|  | ||||
| #include "postgres_fe.h" | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <unistd.h> | ||||
|  | ||||
|   | ||||
							
								
								
									
										266
									
								
								pg_arman.c
									
									
									
									
									
								
							
							
						
						
									
										266
									
								
								pg_arman.c
									
									
									
									
									
								
							| @@ -1,266 +0,0 @@ | ||||
| /*------------------------------------------------------------------------- | ||||
|  * | ||||
|  * pg_arman.c: Backup/Recovery manager for PostgreSQL. | ||||
|  * | ||||
|  * Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION | ||||
|  * | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "streamutil.h" | ||||
|  | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <time.h> | ||||
| #include <sys/stat.h> | ||||
|  | ||||
| const char *PROGRAM_VERSION	= "0.1"; | ||||
| const char *PROGRAM_URL		= "https://github.com/stalkerg/pg_arman"; | ||||
| const char *PROGRAM_EMAIL	= "https://github.com/stalkerg/pg_arman/issues"; | ||||
|  | ||||
| /* path configuration */ | ||||
| char *backup_path; | ||||
| char *pgdata; | ||||
| char arclog_path[MAXPGPATH]; | ||||
|  | ||||
| /* common configuration */ | ||||
| bool check = false; | ||||
|  | ||||
| /* directory configuration */ | ||||
| pgBackup	current; | ||||
|  | ||||
| /* backup configuration */ | ||||
| static bool		smooth_checkpoint; | ||||
| static int		keep_data_generations = KEEP_INFINITE; | ||||
| static int		keep_data_days = KEEP_INFINITE; | ||||
| int				num_threads = 1; | ||||
| bool			stream_wal = false; | ||||
| bool			from_replica = false; | ||||
| static bool		backup_logs = false; | ||||
| bool			progress = false; | ||||
| bool			delete_wal = false; | ||||
|  | ||||
| /* restore configuration */ | ||||
| static char		   *target_time; | ||||
| static char		   *target_xid; | ||||
| static char		   *target_inclusive; | ||||
| static TimeLineID	target_tli; | ||||
|  | ||||
| /* show configuration */ | ||||
| static bool			show_all = false; | ||||
|  | ||||
| static void opt_backup_mode(pgut_option *opt, const char *arg); | ||||
|  | ||||
| static pgut_option options[] = | ||||
| { | ||||
| 	/* directory options */ | ||||
| 	{ 's', 'D', "pgdata",		&pgdata,		SOURCE_ENV }, | ||||
| 	{ 's', 'B', "backup-path",	&backup_path,	SOURCE_ENV }, | ||||
| 	/* common options */ | ||||
| /*	{ 'b', 'c', "check",		&check },*/ | ||||
| 	{ 'i', 'j', "threads",		&num_threads }, | ||||
| 	{ 'b', 8, "stream",			&stream_wal }, | ||||
| 	{ 'b', 11, "progress",		&progress }, | ||||
| 	/* backup options */ | ||||
| 	{ 'b', 10, "backup-pg-log",			&backup_logs }, | ||||
| 	{ 'f', 'b', "backup-mode",			opt_backup_mode,		SOURCE_ENV }, | ||||
| 	{ 'b', 'C', "smooth-checkpoint",	&smooth_checkpoint,		SOURCE_ENV }, | ||||
| 	{ 's', 'S', "slot",					&replication_slot,		SOURCE_ENV }, | ||||
| 	/* options with only long name (keep-xxx) */ | ||||
| /*	{ 'i',  1, "keep-data-generations", &keep_data_generations, SOURCE_ENV }, | ||||
| 	{ 'i',  2, "keep-data-days",		&keep_data_days,		SOURCE_ENV },*/ | ||||
| 	/* restore options */ | ||||
| 	{ 's',  3, "time",		&target_time,		SOURCE_ENV }, | ||||
| 	{ 's',  4, "xid",		&target_xid,		SOURCE_ENV }, | ||||
| 	{ 's',  5, "inclusive", &target_inclusive,	SOURCE_ENV }, | ||||
| 	{ 'u',  6, "timeline",	&target_tli,		SOURCE_ENV }, | ||||
| 	/* catalog options */ | ||||
| 	{ 'b', 'a', "show-all",					&show_all }, | ||||
| 	/* delete options */ | ||||
| 	{ 'b', 12, "wal",						&delete_wal }, | ||||
| 	{ 0 } | ||||
| }; | ||||
|  | ||||
| /* | ||||
|  * Entry point of pg_arman command. | ||||
|  */ | ||||
| int | ||||
| main(int argc, char *argv[]) | ||||
| { | ||||
| 	const char	   *cmd = NULL; | ||||
| 	const char	   *backup_id_string = NULL; | ||||
| 	time_t			backup_id = 0; | ||||
| 	int				i; | ||||
|  | ||||
| 	/* do not buffer progress messages */ | ||||
| 	setvbuf(stdout, 0, _IONBF, 0);	/* TODO: remove this */ | ||||
|  | ||||
| 	/* initialize configuration */ | ||||
| 	catalog_init_config(¤t); | ||||
|  | ||||
| 	/* overwrite configuration with command line arguments */ | ||||
| 	i = pgut_getopt(argc, argv, options); | ||||
|  | ||||
| 	for (; i < argc; i++) | ||||
| 	{ | ||||
| 		if (cmd == NULL) | ||||
| 		{ | ||||
| 			cmd = argv[i]; | ||||
| 			if(strcmp(cmd, "show") != 0 && | ||||
| 			   strcmp(cmd, "validate") != 0 && | ||||
| 			   strcmp(cmd, "delete") != 0 && | ||||
| 			   strcmp(cmd, "restore") != 0 && | ||||
| 			   strcmp(cmd, "delwal") != 0) | ||||
| 				break; | ||||
| 		} else if (backup_id_string == NULL) | ||||
| 			backup_id_string = argv[i]; | ||||
| 		else | ||||
| 			elog(ERROR, "too many arguments"); | ||||
| 	} | ||||
|  | ||||
| 	/* command argument (backup/restore/show/...) is required. */ | ||||
| 	if (cmd == NULL) | ||||
| 	{ | ||||
| 		help(false); | ||||
| 		return 1; | ||||
| 	} | ||||
|  | ||||
| 	if (backup_id_string != NULL) | ||||
| 	{ | ||||
| 		backup_id = base36dec(backup_id_string); | ||||
| 		if (backup_id == 0) { | ||||
| 			elog(ERROR, "wrong ID"); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* Read default configuration from file. */ | ||||
| 	if (backup_path) | ||||
| 	{ | ||||
| 		char	path[MAXPGPATH]; | ||||
| 		/* Check if backup_path is directory. */ | ||||
| 		struct stat stat_buf; | ||||
| 		int rc = stat(backup_path, &stat_buf); | ||||
|  | ||||
| 		/* If rc == -1,  there is no file or directory. So it's OK. */ | ||||
| 		if (rc != -1 && !S_ISDIR(stat_buf.st_mode)) | ||||
| 			elog(ERROR, "-B, --backup-path must be a path to directory"); | ||||
|  | ||||
| 		join_path_components(path, backup_path, PG_RMAN_INI_FILE); | ||||
| 		pgut_readopt(path, options, ERROR); | ||||
|  | ||||
| 		/* setup stream options */ | ||||
| 		if (pgut_dbname != NULL) | ||||
| 			dbname = pstrdup(pgut_dbname); | ||||
| 		if (host != NULL) | ||||
| 			dbhost = pstrdup(host); | ||||
| 		if (port != NULL) | ||||
| 			dbport = pstrdup(port); | ||||
| 		if (username != NULL) | ||||
| 			dbuser = pstrdup(username); | ||||
| 	} | ||||
|  | ||||
| 	/* BACKUP_PATH is always required */ | ||||
| 	if (backup_path == NULL) | ||||
| 		elog(ERROR, "required parameter not specified: BACKUP_PATH (-B, --backup-path)"); | ||||
|  | ||||
| 	/* path must be absolute */ | ||||
| 	if (backup_path != NULL && !is_absolute_path(backup_path)) | ||||
| 		elog(ERROR, "-B, --backup-path must be an absolute path"); | ||||
| 	if (pgdata != NULL && !is_absolute_path(pgdata)) | ||||
| 		elog(ERROR, "-D, --pgdata must be an absolute path"); | ||||
|  | ||||
| 	join_path_components(arclog_path, backup_path, "wal"); | ||||
|  | ||||
| 	/* setup exclusion list for file search */ | ||||
| 	for (i = 0; pgdata_exclude[i]; i++);		/* find first empty slot */ | ||||
|  | ||||
| 	pgdata_exclude[i++] = arclog_path; | ||||
|  | ||||
| 	if(!backup_logs) | ||||
| 		pgdata_exclude[i++] = "pg_log"; | ||||
|  | ||||
| 	if (target_time != NULL && target_xid != NULL) | ||||
| 		elog(ERROR, "You can't specify recovery-target-time and recovery-target-xid at the same time"); | ||||
|  | ||||
| 	/* do actual operation */ | ||||
| 	if (pg_strcasecmp(cmd, "init") == 0) | ||||
| 		return do_init(); | ||||
| 	else if (pg_strcasecmp(cmd, "backup") == 0) | ||||
| 	{ | ||||
| 		pgBackupOption bkupopt; | ||||
| 		int res; | ||||
| 		bkupopt.smooth_checkpoint = smooth_checkpoint; | ||||
| 		bkupopt.keep_data_generations = keep_data_generations; | ||||
| 		bkupopt.keep_data_days = keep_data_days; | ||||
|  | ||||
| 		/* Do the backup */ | ||||
| 		res = do_backup(bkupopt); | ||||
| 		if (res != 0) | ||||
| 			return res; | ||||
|  | ||||
| 		do_validate(current.start_time); | ||||
| 	} | ||||
| 	else if (pg_strcasecmp(cmd, "restore") == 0) | ||||
| 		return do_restore(backup_id, target_time, target_xid, | ||||
| 					target_inclusive, target_tli); | ||||
| 	else if (pg_strcasecmp(cmd, "show") == 0) | ||||
| 		return do_show(backup_id, show_all); | ||||
| 	else if (pg_strcasecmp(cmd, "validate") == 0) | ||||
| 		return do_validate(backup_id); | ||||
| 	else if (pg_strcasecmp(cmd, "delete") == 0) | ||||
| 		return do_delete(backup_id); | ||||
| 	else if (pg_strcasecmp(cmd, "delwal") == 0) | ||||
| 		return do_deletewal(backup_id, true); | ||||
| 	else | ||||
| 		elog(ERROR, "invalid command \"%s\"", cmd); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| void | ||||
| pgut_help(bool details) | ||||
| { | ||||
| 	printf(_("%s manage backup/recovery of PostgreSQL database.\n\n"), PROGRAM_NAME); | ||||
| 	printf(_("Usage:\n")); | ||||
| 	printf(_("  %s OPTION init\n"), PROGRAM_NAME); | ||||
| 	printf(_("  %s OPTION backup\n"), PROGRAM_NAME); | ||||
| 	printf(_("  %s OPTION restore\n"), PROGRAM_NAME); | ||||
| 	printf(_("  %s OPTION show [ID]\n"), PROGRAM_NAME); | ||||
| 	printf(_("  %s OPTION validate [ID]\n"), PROGRAM_NAME); | ||||
| 	printf(_("  %s OPTION delete ID\n"), PROGRAM_NAME); | ||||
| 	printf(_("  %s OPTION delwal [ID]\n"), PROGRAM_NAME); | ||||
|  | ||||
| 	if (!details) | ||||
| 		return; | ||||
|  | ||||
| 	printf(_("\nCommon Options:\n")); | ||||
| 	printf(_("  -D, --pgdata=PATH         location of the database storage area\n")); | ||||
| 	printf(_("  -B, --backup-path=PATH    location of the backup storage area\n")); | ||||
| 	/*printf(_("  -c, --check               show what would have been done\n"));*/ | ||||
| 	printf(_("  -j, --threads=NUM         num threads for backup and restore\n")); | ||||
| 	printf(_("  --progress                show progress copy files\n")); | ||||
| 	printf(_("\nBackup options:\n")); | ||||
| 	printf(_("  -b, --backup-mode=MODE    full,page,ptrack\n")); | ||||
| 	printf(_("  -C, --smooth-checkpoint   do smooth checkpoint before backup\n")); | ||||
| 	printf(_("  --stream                  use stream for save/restore WAL during backup\n")); | ||||
| 	/*printf(_("  --keep-data-generations=N keep GENERATION of full data backup\n")); | ||||
| 	printf(_("  --keep-data-days=DAY      keep enough data backup to recover to DAY days age\n"));*/ | ||||
| 	printf(_("  --backup-pg-log           start backup pg_log directory\n")); | ||||
| 	printf(_("  -S, --slot=SLOTNAME       replication slot to use\n")); | ||||
| 	printf(_("\nRestore options:\n")); | ||||
| 	printf(_("  --time    time stamp up to which recovery will proceed\n")); | ||||
| 	printf(_("  --xid     transaction ID up to which recovery will proceed\n")); | ||||
| 	printf(_("  --inclusive whether we stop just after the recovery target\n")); | ||||
| 	printf(_("  --timeline  recovering into a particular timeline\n")); | ||||
| 	printf(_("\nCatalog options:\n")); | ||||
| 	printf(_("  -a, --show-all            show deleted backup too\n")); | ||||
| 	printf(_("\nDelete options:\n")); | ||||
| 	printf(_("  --wal                     remove unnecessary wal archives also\n")); | ||||
| } | ||||
|  | ||||
| static void | ||||
| opt_backup_mode(pgut_option *opt, const char *arg) | ||||
| { | ||||
| 	current.backup_mode = parse_backup_mode(arg); | ||||
| } | ||||
							
								
								
									
										317
									
								
								pg_arman.h
									
									
									
									
									
								
							
							
						
						
									
										317
									
								
								pg_arman.h
									
									
									
									
									
								
							| @@ -1,317 +0,0 @@ | ||||
| /*------------------------------------------------------------------------- | ||||
|  * | ||||
|  * pg_arman.h: Backup/Recovery manager for PostgreSQL. | ||||
|  * | ||||
|  * Copyright (c) 2009-2013, NIPPON TELEGRAPH AND TELEPHONE CORPORATION | ||||
|  * | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
| #ifndef PG_RMAN_H | ||||
| #define PG_RMAN_H | ||||
|  | ||||
| #include "postgres_fe.h" | ||||
|  | ||||
| #include <limits.h> | ||||
| #include "libpq-fe.h" | ||||
|  | ||||
| #include "pgut/pgut.h" | ||||
| #include "access/xlogdefs.h" | ||||
| #include "access/xlog_internal.h" | ||||
| #include "catalog/pg_control.h" | ||||
| #include "utils/pg_crc.h" | ||||
| #include "parray.h" | ||||
| #include "datapagemap.h" | ||||
| #include "storage/bufpage.h" | ||||
| #include "storage/block.h" | ||||
| #include "storage/checksum.h" | ||||
|  | ||||
| /* Query to fetch current transaction ID */ | ||||
| #define TXID_CURRENT_SQL	"SELECT txid_current();" | ||||
| #define TXID_CURRENT_IF_SQL	"SELECT txid_snapshot_xmax(txid_current_snapshot());" | ||||
|  | ||||
| /* Directory/File names */ | ||||
| #define DATABASE_DIR			"database" | ||||
| #define BACKUPS_DIR				"backups" | ||||
| #define PG_XLOG_DIR				"pg_xlog" | ||||
| #define PG_TBLSPC_DIR			"pg_tblspc" | ||||
| #define BACKUP_INI_FILE			"backup.ini" | ||||
| #define PG_RMAN_INI_FILE		"pg_arman.ini" | ||||
| #define MKDIRS_SH_FILE			"mkdirs.sh" | ||||
| #define DATABASE_FILE_LIST		"file_database.txt" | ||||
| #define PG_BACKUP_LABEL_FILE	"backup_label" | ||||
| #define PG_BLACK_LIST			"black_list" | ||||
|  | ||||
| /* Direcotry/File permission */ | ||||
| #define DIR_PERMISSION		(0700) | ||||
| #define FILE_PERMISSION		(0600) | ||||
|  | ||||
| /* backup mode file */ | ||||
| typedef struct pgFile | ||||
| { | ||||
| 	time_t	mtime;			/* time of last modification */ | ||||
| 	mode_t	mode;			/* protection (file type and permission) */ | ||||
| 	size_t	size;			/* size of the file */ | ||||
| 	size_t	read_size;		/* size of the portion read (if only some pages are | ||||
| 							   backed up partially, it's different from size) */ | ||||
| 	size_t	write_size;		/* size of the backed-up file. BYTES_INVALID means | ||||
| 							   that the file existed but was not backed up | ||||
| 							   because not modified since last backup. */ | ||||
| 	pg_crc32 crc;			/* CRC value of the file, regular file only */ | ||||
| 	char	*linked;			/* path of the linked file */ | ||||
| 	bool	is_datafile;	/* true if the file is PostgreSQL data file */ | ||||
| 	char	*path;			/* path of the file */ | ||||
| 	char	*ptrack_path; | ||||
| 	int		segno;			/* Segment number for ptrack */ | ||||
| 	volatile uint32 lock; | ||||
| 	datapagemap_t pagemap; | ||||
| } pgFile; | ||||
|  | ||||
| #define IsValidTime(tm)	\ | ||||
| 	((tm.tm_sec >= 0 && tm.tm_sec <= 60) && 	/* range check for tm_sec (0-60)  */ \ | ||||
| 	 (tm.tm_min >= 0 && tm.tm_min <= 59) && 	/* range check for tm_min (0-59)  */ \ | ||||
| 	 (tm.tm_hour >= 0 && tm.tm_hour <= 23) && 	/* range check for tm_hour(0-23)  */ \ | ||||
| 	 (tm.tm_mday >= 1 && tm.tm_mday <= 31) && 	/* range check for tm_mday(1-31)  */ \ | ||||
| 	 (tm.tm_mon >= 0 && tm.tm_mon <= 11) && 	/* range check for tm_mon (0-23)  */ \ | ||||
| 	 (tm.tm_year + 1900 >= 1900)) 			/* range check for tm_year(70-)    */ | ||||
|  | ||||
| /* Effective data size */ | ||||
| #define MAPSIZE (BLCKSZ - MAXALIGN(SizeOfPageHeaderData)) | ||||
|  | ||||
| /* Backup status */ | ||||
| /* XXX re-order ? */ | ||||
| typedef enum BackupStatus | ||||
| { | ||||
| 	BACKUP_STATUS_INVALID,		/* the pgBackup is invalid */ | ||||
| 	BACKUP_STATUS_OK,			/* completed backup */ | ||||
| 	BACKUP_STATUS_RUNNING,		/* running backup */ | ||||
| 	BACKUP_STATUS_ERROR,		/* aborted because of unexpected error */ | ||||
| 	BACKUP_STATUS_DELETING,		/* data files are being deleted */ | ||||
| 	BACKUP_STATUS_DELETED,		/* data files have been deleted */ | ||||
| 	BACKUP_STATUS_DONE,			/* completed but not validated yet */ | ||||
| 	BACKUP_STATUS_CORRUPT		/* files are corrupted, not available */ | ||||
| } BackupStatus; | ||||
|  | ||||
| typedef enum BackupMode | ||||
| { | ||||
| 	BACKUP_MODE_INVALID, | ||||
| 	BACKUP_MODE_DIFF_PAGE,		/* differential page backup */ | ||||
| 	BACKUP_MODE_DIFF_PTRACK,	/* differential page backup with ptrack system*/ | ||||
| 	BACKUP_MODE_FULL			/* full backup */ | ||||
| } BackupMode; | ||||
|  | ||||
| /* | ||||
|  * pg_arman takes backup into the directroy $BACKUP_PATH/<date>/<time>. | ||||
|  * | ||||
|  * status == -1 indicates the pgBackup is invalid. | ||||
|  */ | ||||
| typedef struct pgBackup | ||||
| { | ||||
| 	/* Backup Level */ | ||||
| 	BackupMode	backup_mode; | ||||
|  | ||||
| 	/* Status - one of BACKUP_STATUS_xxx */ | ||||
| 	BackupStatus	status; | ||||
|  | ||||
| 	/* Timestamp, etc. */ | ||||
| 	TimeLineID	tli; | ||||
| 	XLogRecPtr	start_lsn; | ||||
| 	XLogRecPtr	stop_lsn; | ||||
| 	time_t		start_time; | ||||
| 	time_t		end_time; | ||||
| 	time_t		recovery_time; | ||||
| 	uint32		recovery_xid; | ||||
|  | ||||
| 	/* Different sizes (-1 means nothing was backed up) */ | ||||
| 	/* | ||||
| 	 * Amount of raw data. For a full backup, this is the total amount of | ||||
| 	 * data while for a differential backup this is just the difference | ||||
| 	 * of data taken. | ||||
| 	 */ | ||||
| 	int64		data_bytes; | ||||
|  | ||||
| 	/* data/wal block size for compatibility check */ | ||||
| 	uint32		block_size; | ||||
| 	uint32		wal_block_size; | ||||
| 	uint32		checksum_version; | ||||
| 	bool		stream; | ||||
| } pgBackup; | ||||
|  | ||||
| typedef struct pgBackupOption | ||||
| { | ||||
| 	bool smooth_checkpoint; | ||||
| 	int  keep_data_generations; | ||||
| 	int  keep_data_days; | ||||
| } pgBackupOption; | ||||
|  | ||||
|  | ||||
| /* special values of pgBackup */ | ||||
| #define KEEP_INFINITE			(INT_MAX) | ||||
| #define BYTES_INVALID			(-1) | ||||
|  | ||||
| typedef struct pgTimeLine | ||||
| { | ||||
| 	TimeLineID	tli; | ||||
| 	XLogRecPtr	end; | ||||
| } pgTimeLine; | ||||
|  | ||||
| typedef struct pgRecoveryTarget | ||||
| { | ||||
| 	bool		time_specified; | ||||
| 	time_t		recovery_target_time; | ||||
| 	bool		xid_specified; | ||||
| 	unsigned int	recovery_target_xid; | ||||
| 	bool		recovery_target_inclusive; | ||||
| } pgRecoveryTarget; | ||||
|  | ||||
| typedef union DataPage | ||||
| { | ||||
| 	PageHeaderData	page_data; | ||||
| 	char			data[BLCKSZ]; | ||||
| } DataPage; | ||||
|  | ||||
| /* | ||||
|  * return pointer that exceeds the length of prefix from character string. | ||||
|  * ex. str="/xxx/yyy/zzz", prefix="/xxx/yyy", return="zzz". | ||||
|  */ | ||||
| #define JoinPathEnd(str, prefix) \ | ||||
| 	((strlen(str) <= strlen(prefix)) ? "" : str + strlen(prefix) + 1) | ||||
|  | ||||
| /* | ||||
|  * Return timeline, xlog ID and record offset from an LSN of the type | ||||
|  * 0/B000188, usual result from pg_stop_backup() and friends. | ||||
|  */ | ||||
| #define XLogDataFromLSN(data, xlogid, xrecoff)		\ | ||||
| 	sscanf(data, "%X/%X", xlogid, xrecoff) | ||||
|  | ||||
| /* path configuration */ | ||||
| extern char *backup_path; | ||||
| extern char *pgdata; | ||||
| extern char arclog_path[MAXPGPATH]; | ||||
|  | ||||
| /* common configuration */ | ||||
| extern bool check; | ||||
|  | ||||
| /* current settings */ | ||||
| extern pgBackup current; | ||||
|  | ||||
| /* exclude directory list for $PGDATA file listing */ | ||||
| extern const char *pgdata_exclude[]; | ||||
|  | ||||
| /* backup file list from non-snapshot */ | ||||
| extern parray *backup_files_list; | ||||
|  | ||||
| extern int num_threads; | ||||
| extern bool stream_wal; | ||||
| extern bool from_replica; | ||||
| extern bool progress; | ||||
| extern bool delete_wal; | ||||
|  | ||||
| /* in backup.c */ | ||||
| extern int do_backup(pgBackupOption bkupopt); | ||||
| extern BackupMode parse_backup_mode(const char *value); | ||||
| extern void check_server_version(void); | ||||
| extern bool fileExists(const char *path); | ||||
| extern void process_block_change(ForkNumber forknum, RelFileNode rnode, | ||||
| 								 BlockNumber blkno); | ||||
|  | ||||
| /* in restore.c */ | ||||
| extern int do_restore(time_t backup_id, | ||||
| 					  const char *target_time, | ||||
| 					  const char *target_xid, | ||||
| 					  const char *target_inclusive, | ||||
| 					  TimeLineID target_tli); | ||||
|  | ||||
| /* in init.c */ | ||||
| extern int do_init(void); | ||||
|  | ||||
| /* in show.c */ | ||||
| extern int do_show(time_t backup_id, bool show_all); | ||||
|  | ||||
| /* in delete.c */ | ||||
| extern int do_delete(time_t backup_id); | ||||
| extern void pgBackupDelete(int keep_generations, int keep_days); | ||||
| extern int do_deletewal(time_t backup_id, bool strict); | ||||
|  | ||||
| /* in fetch.c */ | ||||
| extern char *slurpFile(const char *datadir, | ||||
| 					   const char *path, | ||||
| 					   size_t *filesize, | ||||
| 					   bool safe); | ||||
|  | ||||
| /* in validate.c */ | ||||
| extern int do_validate(time_t backup_id); | ||||
| extern void pgBackupValidate(pgBackup *backup, | ||||
| 							 bool size_only, | ||||
| 							 bool for_get_timeline); | ||||
|  | ||||
| /* in catalog.c */ | ||||
| extern pgBackup *catalog_get_backup(time_t timestamp); | ||||
| extern parray *catalog_get_backup_list(time_t backup_id); | ||||
| extern pgBackup *catalog_get_last_data_backup(parray *backup_list, | ||||
| 											  TimeLineID tli); | ||||
|  | ||||
| extern int catalog_lock(void); | ||||
| extern void catalog_unlock(void); | ||||
|  | ||||
| extern void catalog_init_config(pgBackup *backup); | ||||
|  | ||||
| extern void pgBackupWriteConfigSection(FILE *out, pgBackup *backup); | ||||
| extern void pgBackupWriteResultSection(FILE *out, pgBackup *backup); | ||||
| extern void pgBackupWriteIni(pgBackup *backup); | ||||
| extern void pgBackupGetPath(const pgBackup *backup, char *path, size_t len, const char *subdir); | ||||
| extern int pgBackupCreateDir(pgBackup *backup); | ||||
| extern void pgBackupFree(void *backup); | ||||
| extern int pgBackupCompareId(const void *f1, const void *f2); | ||||
| extern int pgBackupCompareIdDesc(const void *f1, const void *f2); | ||||
|  | ||||
| /* in dir.c */ | ||||
| extern void dir_list_file(parray *files, const char *root, const char *exclude[], bool omit_symlink, bool add_root); | ||||
| extern void dir_list_file_internal(parray *files, const char *root, const char *exclude[], | ||||
| 					bool omit_symlink, bool add_root, parray *black_list); | ||||
| extern void dir_print_mkdirs_sh(FILE *out, const parray *files, const char *root); | ||||
| extern void dir_print_file_list(FILE *out, const parray *files, const char *root, const char *prefix); | ||||
| extern parray *dir_read_file_list(const char *root, const char *file_txt); | ||||
|  | ||||
| extern int dir_create_dir(const char *path, mode_t mode); | ||||
| extern void dir_copy_files(const char *from_root, const char *to_root); | ||||
|  | ||||
| extern pgFile *pgFileNew(const char *path, bool omit_symlink); | ||||
| extern void pgFileDelete(pgFile *file); | ||||
| extern void pgFileFree(void *file); | ||||
| extern pg_crc32 pgFileGetCRC(pgFile *file); | ||||
| extern int pgFileComparePath(const void *f1, const void *f2); | ||||
| extern int pgFileComparePathDesc(const void *f1, const void *f2); | ||||
| extern int pgFileCompareSize(const void *f1, const void *f2); | ||||
| extern int pgFileCompareMtime(const void *f1, const void *f2); | ||||
| extern int pgFileCompareMtimeDesc(const void *f1, const void *f2); | ||||
|  | ||||
| /* in data.c */ | ||||
| extern bool backup_data_file(const char *from_root, const char *to_root, | ||||
| 							 pgFile *file, const XLogRecPtr *lsn); | ||||
| extern void restore_data_file(const char *from_root, const char *to_root, | ||||
| 							  pgFile *file, pgBackup *backup); | ||||
| extern bool copy_file(const char *from_root, const char *to_root, | ||||
| 					  pgFile *file); | ||||
|  | ||||
| extern bool calc_file(pgFile *file); | ||||
|  | ||||
| /* parsexlog.c */ | ||||
| extern void extractPageMap(const char *datadir, XLogRecPtr startpoint, | ||||
| 						   TimeLineID tli, XLogRecPtr endpoint); | ||||
|  | ||||
| /* in util.c */ | ||||
| extern TimeLineID get_current_timeline(bool safe); | ||||
| extern void sanityChecks(void); | ||||
| extern void time2iso(char *buf, size_t len, time_t time); | ||||
| extern const char *status2str(BackupStatus status); | ||||
| extern void remove_trailing_space(char *buf, int comment_mark); | ||||
| extern void remove_not_digit(char *buf, size_t len, const char *str); | ||||
| extern XLogRecPtr get_last_ptrack_lsn(void); | ||||
| extern uint32 get_data_checksum_version(bool safe); | ||||
| extern char *base36enc(long unsigned int value); | ||||
| extern long unsigned int base36dec(const char *text); | ||||
|  | ||||
| /* in status.c */ | ||||
| extern bool is_pg_running(void); | ||||
|  | ||||
| #endif /* PG_RMAN_H */ | ||||
| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <fcntl.h> | ||||
| #include <sys/stat.h> | ||||
| @@ -84,7 +84,7 @@ do_restore(time_t backup_id, | ||||
| 		elog(ERROR, "cannot lock backup catalog."); | ||||
| 	else if (ret == 1) | ||||
| 		elog(ERROR, | ||||
| 			"another pg_arman is running, stop restore."); | ||||
| 			"another pg_probackup is running, stop restore."); | ||||
|  | ||||
| 	/* confirm the PostgreSQL server is not running */ | ||||
| 	if (is_pg_running()) | ||||
| @@ -484,7 +484,7 @@ create_recovery_conf(time_t backup_id, | ||||
| 			elog(ERROR, "cannot open recovery.conf \"%s\": %s", path, | ||||
| 				strerror(errno)); | ||||
|  | ||||
| 		fprintf(fp, "# recovery.conf generated by pg_arman %s\n", | ||||
| 		fprintf(fp, "# recovery.conf generated by pg_probackup %s\n", | ||||
| 			PROGRAM_VERSION); | ||||
| 		fprintf(fp, "restore_command = 'cp %s/%%f %%p'\n", arclog_path); | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								show.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								show.c
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| static void show_backup_list(FILE *out, parray *backup_list, bool show_all); | ||||
| static void show_backup_detail(FILE *out, pgBackup *backup); | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| #============================================================================ | ||||
| # This is a test script for backup command of pg_arman. | ||||
| # This is a test script for backup command of pg_probackup. | ||||
| #============================================================================ | ||||
|  | ||||
| # Load common rules | ||||
| @@ -11,37 +11,37 @@ init_backup | ||||
|  | ||||
| echo '###### BACKUP COMMAND TEST-0001 ######' | ||||
| echo '###### full backup mode ######' | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0001-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0001-run.log 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0001-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0001-run.log 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.log 2>&1 | ||||
| grep -c OK ${TEST_BASE}/TEST-0001.log | ||||
| grep OK ${TEST_BASE}/TEST-0001.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//' | ||||
|  | ||||
| echo '###### BACKUP COMMAND TEST-0002 ######' | ||||
| echo '###### page-level backup mode ######' | ||||
| pg_arman backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0002-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0002-run.log 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0002-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0002-run.log 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.log 2>&1 | ||||
| grep -c OK ${TEST_BASE}/TEST-0002.log | ||||
| grep OK ${TEST_BASE}/TEST-0002.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//' | ||||
|  | ||||
| echo '###### BACKUP COMMAND TEST-0003 ######' | ||||
| echo '###### full backup with smooth checkpoint ######' | ||||
| init_catalog | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -C -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0003-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0003-run.log 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0003.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -C -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0003-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0003-run.log 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0003.log 2>&1 | ||||
| grep -c OK ${TEST_BASE}/TEST-0003.log | ||||
| grep OK ${TEST_BASE}/TEST-0003.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//' | ||||
|  | ||||
| #echo '###### BACKUP COMMAND TEST-0004 ######' | ||||
| #echo '###### full backup with keep-data-generations and keep-data-days ######' | ||||
| #init_catalog | ||||
| #pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $? | ||||
| #pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $? | ||||
| #pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $? | ||||
| #pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1 | ||||
| #pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0004-before.log 2>&1 | ||||
| #pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $? | ||||
| #pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $? | ||||
| #pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1;echo $? | ||||
| #pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0004-run.log 2>&1 | ||||
| #pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0004-before.log 2>&1 | ||||
| #NUM_OF_FULL_BACKUPS_BEFORE=`grep OK ${TEST_BASE}/TEST-0004-before.log | grep FULL | wc -l | sed 's/^ *//'` | ||||
| #if [ ${NUM_OF_FULL_BACKUPS_BEFORE} -gt 2 ] ; then | ||||
| #	echo "The number of existing full backups validated is greater than 2." | ||||
| @@ -55,9 +55,9 @@ grep OK ${TEST_BASE}/TEST-0003.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//' | ||||
| ## The actual value of NUM_OF_FULL_BACKUPS_BEFORE can vary on env, so commented out as default. | ||||
| ##echo "Number of existing full backups validated: ${NUM_OF_FULL_BACKUPS_BEFORE}" | ||||
| #grep OK ${TEST_BASE}/TEST-0004-before.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//' | ||||
| #pg_arman backup -B ${BACKUP_PATH} -b full --keep-data-days=-1 --keep-data-generations=1 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0005-run.log 2>&1;echo $? | ||||
| #pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0005-run.log 2>&1 | ||||
| #pg_arman show --show-all -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0004-after.log 2>&1 | ||||
| #pg_probackup backup -B ${BACKUP_PATH} -b full --keep-data-days=-1 --keep-data-generations=1 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0005-run.log 2>&1;echo $? | ||||
| #pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0005-run.log 2>&1 | ||||
| #pg_probackup show --show-all -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0004-after.log 2>&1 | ||||
| #NUM_OF_FULL_BACKUPS_AFTER=`grep OK ${TEST_BASE}/TEST-0004-after.log | grep FULL | wc -l | sed 's/^ *//'` | ||||
| #echo "Number of remaining full backups validated: ${NUM_OF_FULL_BACKUPS_AFTER}" | ||||
| #NUM_OF_DELETED_BACKUPS=`grep DELETED ${TEST_BASE}/TEST-0004-after.log | wc -l | sed 's/^ *//'` | ||||
| @@ -68,42 +68,42 @@ echo '###### BACKUP COMMAND TEST-0005 ######' | ||||
| echo '###### switch backup mode from page to full ######' | ||||
| init_catalog | ||||
| echo 'page-level backup without validated full backup' | ||||
| pg_arman backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0005.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0005.log 2>&1 | ||||
| grep OK ${TEST_BASE}/TEST-0005.log | grep FULL | wc -l | sed 's/^ *//' | ||||
| grep ERROR ${TEST_BASE}/TEST-0005.log | grep INCR | wc -l | sed 's/^ *//' | ||||
|  | ||||
| echo '###### BACKUP COMMAND TEST-0006 ######' | ||||
| echo '###### ptrack backup mode ######' | ||||
| init_catalog | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0006-run.log 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0006.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0006-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0006-run.log 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0006.log 2>&1 | ||||
| grep -c OK ${TEST_BASE}/TEST-0006.log | ||||
| grep OK ${TEST_BASE}/TEST-0006.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//' | ||||
|  | ||||
| echo '###### BACKUP COMMAND TEST-0007 ######' | ||||
| echo '###### ptrack multi thread backup mode ######' | ||||
| init_catalog | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.log 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0007-run.log 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0007.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0007-run.log 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0007.log 2>&1 | ||||
| grep -c OK ${TEST_BASE}/TEST-0007.log | ||||
| grep OK ${TEST_BASE}/TEST-0007.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//' | ||||
|  | ||||
| echo '###### BACKUP COMMAND TEST-0008 ######' | ||||
| echo '###### ptrack multi thread backup mode + stream ######' | ||||
| init_catalog | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0008-run.log 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.log 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0008-run.log 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0008.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0008-run.log 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.log 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} >> ${TEST_BASE}/TEST-0008-run.log 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0008.log 2>&1 | ||||
| grep -c OK ${TEST_BASE}/TEST-0008.log | ||||
| grep OK ${TEST_BASE}/TEST-0008.log | sed -e 's@[^-]@@g' | wc -c | sed 's/^ *//' | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| TEST_NAME=$1 | ||||
|  | ||||
| # Unset environment variables usable by both Postgres and pg_arman | ||||
| # Unset environment variables usable by both Postgres and pg_probackup | ||||
| unset PGUSER | ||||
| unset PGPORT | ||||
| unset PGDATABASE | ||||
| @@ -55,7 +55,7 @@ function cleanup() | ||||
| function init_catalog() | ||||
| { | ||||
| 	rm -fr ${BACKUP_PATH} | ||||
| 	pg_arman init -B ${BACKUP_PATH} --quiet | ||||
| 	pg_probackup init -B ${BACKUP_PATH} --quiet | ||||
| } | ||||
|  | ||||
| function init_backup() | ||||
| @@ -95,8 +95,8 @@ function get_time_last_backup() | ||||
| 	name_os=`uname` | ||||
| 	if [ "$name_os" == "SunOS" ] | ||||
| 	then | ||||
| 		pg_arman -B ${BACKUP_PATH} show | gtail -n +4 | head -n 1 | awk '{print($1)}' | ||||
| 		pg_probackup -B ${BACKUP_PATH} show | gtail -n +4 | head -n 1 | awk '{print($1)}' | ||||
| 	else | ||||
| 		pg_arman -B ${BACKUP_PATH} show | tail -n +4 | head -n 1 | awk '{print($1)}' | ||||
| 		pg_probackup -B ${BACKUP_PATH} show | tail -n +4 | head -n 1 | awk '{print($1)}' | ||||
| 	fi | ||||
| } | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| #============================================================================ | ||||
| # This is a test script for delete command of pg_arman. | ||||
| # This is a test script for delete command of pg_probackup. | ||||
| #============================================================================ | ||||
|  | ||||
| # Load common rules | ||||
| @@ -10,20 +10,20 @@ | ||||
| init_backup | ||||
| echo '###### DELETE COMMAND TEST-0001 ######' | ||||
| echo '###### delete full backups ######' | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| FIRST_BACKUP_DATE=$(get_time_last_backup) | ||||
| pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| SECOND_BACKUP_DATE=$(get_time_last_backup) | ||||
| pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| THIRD_BACKUP_DATE=$(get_time_last_backup) | ||||
| pg_arman validate -B ${BACKUP_PATH} --quiet | ||||
| pg_probackup validate -B ${BACKUP_PATH} --quiet | ||||
|  | ||||
| echo "try to delete the oldest backup" | ||||
| pg_arman -B ${BACKUP_PATH} delete ${SECOND_BACKUP_DATE} > /dev/null 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.out.1 2>&1 | ||||
| pg_arman show -a -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.out.2 2>&1 | ||||
| pg_probackup -B ${BACKUP_PATH} delete ${SECOND_BACKUP_DATE} > /dev/null 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.out.1 2>&1 | ||||
| pg_probackup show -a -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001.out.2 2>&1 | ||||
| grep -c OK ${TEST_BASE}/TEST-0001.out.1 | ||||
| grep -c DELETED ${TEST_BASE}/TEST-0001.out.2 | ||||
| NUM_OF_DELETED_BACKUPS=`grep DELETED ${TEST_BASE}/TEST-0001.out.2 | wc -l | sed 's/^ *//'` | ||||
| @@ -32,24 +32,24 @@ echo "Number of deleted backups should be 1, is it so?: ${NUM_OF_DELETED_BACKUPS | ||||
| init_backup | ||||
| echo '###### DELETE COMMAND TEST-0002 ######' | ||||
| echo '###### keep backups which are necessary for recovery ######' | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| FIRST_BACKUP_DATE=$(get_time_last_backup) | ||||
| pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| SECOND_BACKUP_DATE=$(get_time_last_backup) | ||||
| pg_arman validate -B ${BACKUP_PATH} --quiet | ||||
| pg_probackup validate -B ${BACKUP_PATH} --quiet | ||||
| pgbench -p ${TEST_PGPORT} >> ${TEST_BASE}/pgbench.log 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --quiet | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --quiet | ||||
| THIRD_BACKUP_DATE=$(get_time_last_backup) | ||||
| pg_arman validate -B ${BACKUP_PATH} --quiet | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| pg_probackup validate -B ${BACKUP_PATH} --quiet | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet | ||||
| FOURTH_BACKUP_DATE=$(get_time_last_backup) | ||||
| pg_arman validate -B ${BACKUP_PATH} --quiet | ||||
| pg_probackup validate -B ${BACKUP_PATH} --quiet | ||||
|  | ||||
| echo "try to delete before third backup" | ||||
| pg_arman delete -B ${BACKUP_PATH} ${THIRD_BACKUP_DATE} > /dev/null 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.out.1 2>&1 | ||||
| pg_arman show -a -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.out.2 2>&1 | ||||
| pg_probackup delete -B ${BACKUP_PATH} ${THIRD_BACKUP_DATE} > /dev/null 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.out.1 2>&1 | ||||
| pg_probackup show -a -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002.out.2 2>&1 | ||||
| grep -c OK ${TEST_BASE}/TEST-0002.out.1 | ||||
| grep -c DELETED ${TEST_BASE}/TEST-0002.out.2 | ||||
| NUM_OF_DELETED_BACKUPS=`grep DELETED ${TEST_BASE}/TEST-0002.out.2 | wc -l | sed 's/^ *//'` | ||||
|   | ||||
							
								
								
									
										12
									
								
								sql/init.sh
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								sql/init.sh
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| #============================================================================ | ||||
| # This is a test script for init command of pg_arman. | ||||
| # This is a test script for init command of pg_probackup. | ||||
| #============================================================================ | ||||
|  | ||||
| # Load common rules | ||||
| @@ -22,7 +22,7 @@ EOF | ||||
|  | ||||
| echo '###### INIT COMMAND TEST-0001 ######' | ||||
| echo '###### success with archive_command ######' | ||||
| pg_arman -B ${BACKUP_PATH} init --quiet;echo $? | ||||
| pg_probackup -B ${BACKUP_PATH} init --quiet;echo $? | ||||
| find results/init/backup | xargs ls -Fd | sort | ||||
|  | ||||
| echo '###### INIT COMMAND TEST-0002 ######' | ||||
| @@ -35,7 +35,7 @@ archive_mode = on | ||||
| archive_command = 'cp "%p" "${ARCLOG_PATH}/%f"' | ||||
| log_directory = '${SRVLOG_PATH}' | ||||
| EOF | ||||
| pg_arman -B ${BACKUP_PATH} init --quiet;echo $? | ||||
| pg_probackup -B ${BACKUP_PATH} init --quiet;echo $? | ||||
| find results/init/backup | xargs ls -Fd | sort | ||||
|  | ||||
| echo '###### INIT COMMAND TEST-0003 ######' | ||||
| @@ -47,18 +47,18 @@ wal_level = hot_standby | ||||
| archive_mode = on | ||||
| log_directory = '${SRVLOG_PATH}' | ||||
| EOF | ||||
| pg_arman -B ${BACKUP_PATH} init --quiet;echo $? | ||||
| pg_probackup -B ${BACKUP_PATH} init --quiet;echo $? | ||||
| find results/init/backup | xargs ls -Fd | sort | ||||
|  | ||||
| echo '###### INIT COMMAND TEST-0004 ######' | ||||
| echo '###### failure with backup catalog already existed ######' | ||||
| pg_arman -B ${BACKUP_PATH} init;echo $? | ||||
| pg_probackup -B ${BACKUP_PATH} init;echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### INIT COMMAND TEST-0005 ######' | ||||
| echo '###### failure with backup catalog should be given as absolute path ######' | ||||
| rm -rf ${BACKUP_PATH} | ||||
| pg_arman --backup-path=resuts/init/backup init;echo $? | ||||
| pg_probackup --backup-path=resuts/init/backup init;echo $? | ||||
| echo '' | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| #============================================================================ | ||||
| # This is a test script for options of pg_arman. | ||||
| # This is a test script for options of pg_probackup. | ||||
| #============================================================================ | ||||
|  | ||||
| # Load common rules | ||||
| @@ -11,77 +11,77 @@ cleanup | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0001 ######' | ||||
| echo '###### help option ######' | ||||
| pg_arman --help;echo $? | ||||
| pg_probackup --help;echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0002 ######' | ||||
| echo '###### version option ######' | ||||
| pg_arman --version;echo $? | ||||
| pg_probackup --version;echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0003 ######' | ||||
| echo '###### backup command failure without backup path option ######' | ||||
| pg_arman backup -b full -p ${TEST_PGPORT};echo $? | ||||
| pg_probackup backup -b full -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0004 ######' | ||||
| echo '###### backup command failure without backup mode option ######' | ||||
| pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $? | ||||
| pg_probackup backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0005 ######' | ||||
| echo '###### backup command failure with invalid backup mode option ######' | ||||
| pg_arman backup -B ${BACKUP_PATH} -b bad -p ${TEST_PGPORT};echo $? | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b bad -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0007 ######' | ||||
| echo '###### delete failure without DATE ######' | ||||
| pg_arman delete -B ${BACKUP_PATH};echo $? | ||||
| pg_probackup delete -B ${BACKUP_PATH};echo $? | ||||
| echo '' | ||||
|  | ||||
| init_backup | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0008 ######' | ||||
| echo '###### syntax error in pg_arman.ini ######' | ||||
| echo " = INFINITE" >> ${BACKUP_PATH}/pg_arman.ini | ||||
| pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $? | ||||
| echo '###### syntax error in pg_probackup.conf ######' | ||||
| echo " = INFINITE" >> ${BACKUP_PATH}/pg_probackup.conf | ||||
| pg_probackup backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0009 ######' | ||||
| echo '###### invalid value in pg_arman.ini ######' | ||||
| echo '###### invalid value in pg_probackup.conf ######' | ||||
| init_catalog | ||||
| echo "BACKUP_MODE=" >> ${BACKUP_PATH}/pg_arman.ini | ||||
| pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $? | ||||
| echo "BACKUP_MODE=" >> ${BACKUP_PATH}/pg_probackup.conf | ||||
| pg_probackup backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0010 ######' | ||||
| echo '###### invalid value in pg_arman.ini ######' | ||||
| echo '###### invalid value in pg_probackup.conf ######' | ||||
| init_catalog | ||||
| echo "KEEP_DATA_GENERATIONS=TRUE" >> ${BACKUP_PATH}/pg_arman.ini | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $? | ||||
| echo "KEEP_DATA_GENERATIONS=TRUE" >> ${BACKUP_PATH}/pg_probackup.conf | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0011 ######' | ||||
| echo '###### invalid value in pg_arman.ini ######' | ||||
| echo '###### invalid value in pg_probackup.conf ######' | ||||
| init_catalog | ||||
| echo "SMOOTH_CHECKPOINT=FOO" >> ${BACKUP_PATH}/pg_arman.ini | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $? | ||||
| echo "SMOOTH_CHECKPOINT=FOO" >> ${BACKUP_PATH}/pg_probackup.conf | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0012 ######' | ||||
| echo '###### invalid option in pg_arman.ini ######' | ||||
| echo '###### invalid option in pg_probackup.conf ######' | ||||
| init_catalog | ||||
| echo "TIMELINEID=1" >> ${BACKUP_PATH}/pg_arman.ini | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $? | ||||
| echo "TIMELINEID=1" >> ${BACKUP_PATH}/pg_probackup.conf | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| echo '###### COMMAND OPTION TEST-0013 ######' | ||||
| echo '###### check priority of several pg_arman.ini files ######' | ||||
| echo '###### check priority of several pg_probackup.conf files ######' | ||||
| init_catalog | ||||
| mkdir -p ${BACKUP_PATH}/conf_path_a | ||||
| echo "BACKUP_MODE=ENV_PATH" > ${BACKUP_PATH}/pg_arman.ini | ||||
| echo "BACKUP_MODE=ENV_PATH_A" > ${BACKUP_PATH}/conf_path_a/pg_arman.ini | ||||
| pg_arman backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $? | ||||
| echo "BACKUP_MODE=ENV_PATH" > ${BACKUP_PATH}/pg_probackup.conf | ||||
| echo "BACKUP_MODE=ENV_PATH_A" > ${BACKUP_PATH}/conf_path_a/pg_probackup.conf | ||||
| pg_probackup backup -B ${BACKUP_PATH} -p ${TEST_PGPORT};echo $? | ||||
| echo '' | ||||
|  | ||||
| # clean up the temporal test data | ||||
|   | ||||
							
								
								
									
										100
									
								
								sql/restore.sh
									
									
									
									
									
								
							
							
						
						
									
										100
									
								
								sql/restore.sh
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| #============================================================================ | ||||
| # This is a test script for restore command of pg_arman. | ||||
| # This is a test script for restore command of pg_probackup. | ||||
| #============================================================================ | ||||
|  | ||||
| # Load common rules | ||||
| @@ -30,10 +30,10 @@ init_backup | ||||
| pgbench_objs 0001 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0001-before.out | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0001-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0001-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0001-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0001-run.out 2>&1 | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} -j 4 --verbose >> ${TEST_BASE}/TEST-0001-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} -j 4 --verbose >> ${TEST_BASE}/TEST-0001-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0001-after.out | ||||
| diff ${TEST_BASE}/TEST-0001-before.out ${TEST_BASE}/TEST-0001-after.out | ||||
| @@ -43,14 +43,14 @@ echo '###### RESTORE COMMAND TEST-0002 ######' | ||||
| echo '###### recovery to latest from full + page backups ######' | ||||
| init_backup | ||||
| pgbench_objs 0002 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b page -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0002-before.out | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} -j 4 --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} -j 4 --verbose >> ${TEST_BASE}/TEST-0002-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0002-after.out | ||||
| diff ${TEST_BASE}/TEST-0002-before.out ${TEST_BASE}/TEST-0002-after.out | ||||
| @@ -61,15 +61,15 @@ echo '###### recovery to target timeline ######' | ||||
| init_backup | ||||
| pgbench_objs 0003 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0003-before.out | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1 | ||||
| TARGET_TLI=`pg_controldata | grep " TimeLineID:" | awk '{print $4}'` | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --timeline=${TARGET_TLI} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --timeline=${TARGET_TLI} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1;echo $? | ||||
| echo "checking recovery.conf..." | ||||
| TARGET_TLI_IN_RECOVERY_CONF=`grep "recovery_target_timeline = " ${PGDATA_PATH}/recovery.conf | awk '{print $3}' | sed -e "s/'//g"` | ||||
| if [ ${TARGET_TLI} = ${TARGET_TLI_IN_RECOVERY_CONF} ]; then | ||||
| @@ -90,12 +90,12 @@ init_backup | ||||
| pgbench_objs 0004 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0004-before.out | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0004-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0004-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0004-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0004-run.out 2>&1 | ||||
| TARGET_TIME=`date +"%Y-%m-%d %H:%M:%S"` | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --time="${TARGET_TIME}" --verbose >> ${TEST_BASE}/TEST-0004-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --time="${TARGET_TIME}" --verbose >> ${TEST_BASE}/TEST-0004-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0004-after.out | ||||
| diff ${TEST_BASE}/TEST-0004-before.out ${TEST_BASE}/TEST-0004-after.out | ||||
| @@ -106,8 +106,8 @@ echo '###### recovery to target XID ######' | ||||
| init_backup | ||||
| pgbench_objs 0005 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "CREATE TABLE tbl0005 (a text);" > /dev/null 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0005-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0005-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0005-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0005-run.out 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} pgbench > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0005-before.out | ||||
| TARGET_XID=`psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -tAq -c "INSERT INTO tbl0005 VALUES ('inserted') RETURNING (xmin);"` | ||||
| @@ -118,7 +118,7 @@ pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c 'SELECT pg_switch_xlog()' > /dev/null 2>&1 | ||||
| # Fast mode is used to ensure that the last segment is archived as well. | ||||
| pg_ctl stop -m fast > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --xid="${TARGET_XID}" --verbose >> ${TEST_BASE}/TEST-0005-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --xid="${TARGET_XID}" --verbose >> ${TEST_BASE}/TEST-0005-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0005-after.out | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM tbl0005;" > ${TEST_BASE}/TEST-0005-tbl.dump | ||||
| @@ -136,14 +136,14 @@ echo '###### RESTORE COMMAND TEST-0006 ######' | ||||
| echo '###### recovery to latest from full + ptrack backups ######' | ||||
| init_backup | ||||
| pgbench_objs 0006 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0006-before.out | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0006-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0006-after.out | ||||
| diff ${TEST_BASE}/TEST-0006-before.out ${TEST_BASE}/TEST-0006-after.out | ||||
| @@ -153,18 +153,18 @@ echo '###### RESTORE COMMAND TEST-0007 ######' | ||||
| echo '###### recovery to latest from full + ptrack + ptrack backups ######' | ||||
| init_backup | ||||
| pgbench_objs 0007 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0007-show.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0007-show.out 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0007-before.out | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0007-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0007-after.out | ||||
| diff ${TEST_BASE}/TEST-0007-before.out ${TEST_BASE}/TEST-0007-after.out | ||||
| @@ -174,14 +174,14 @@ echo '###### RESTORE COMMAND TEST-0011 ######' | ||||
| echo '###### recovery in stream mode to latest from full + ptrack backups ######' | ||||
| init_backup | ||||
| pgbench_objs 0006 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 --stream -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0011-before.out | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --stream --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --stream --verbose >> ${TEST_BASE}/TEST-0011-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| sleep 5 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0011-after.out | ||||
| @@ -192,17 +192,17 @@ echo '###### RESTORE COMMAND TEST-0010 ######' | ||||
| echo '###### recovery to latest from full + page backups with loads when ptrack backup do ######' | ||||
| init_backup | ||||
| pgbench_objs 0010 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench -c 4 -T 8 > /dev/null 2>&1 & | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1 | ||||
| sleep 12 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(bbalance) FROM pgbench_branches;" > ${TEST_BASE}/TEST-0010-count1.out | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(delta) FROM pgbench_history;" > ${TEST_BASE}/TEST-0010-count2.out | ||||
| diff ${TEST_BASE}/TEST-0010-count1.out ${TEST_BASE}/TEST-0010-count2.out | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0010-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(bbalance) FROM pgbench_branches;" > ${TEST_BASE}/TEST-0010-count1.out | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(delta) FROM pgbench_history;" > ${TEST_BASE}/TEST-0010-count2.out | ||||
| @@ -217,18 +217,18 @@ init_backup | ||||
| pgbench_objs 0009 | ||||
| pgbench -p ${TEST_PGPORT} -d pgbench -c 4 -T 8 > /dev/null 2>&1 & | ||||
| #PGBENCH_PID=$! | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1 | ||||
| #kill $PGBENCH_PID 2> /dev/null | ||||
| sleep 12 | ||||
| #psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT count(*) FROM pgbench_history;" > ${TEST_BASE}/TEST-0009-count1.out | ||||
| pg_arman backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b ptrack -j 4 -p ${TEST_PGPORT} -d postgres --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(bbalance) FROM pgbench_branches;" > ${TEST_BASE}/TEST-0009-count1.out | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(delta) FROM pgbench_history;" > ${TEST_BASE}/TEST-0009-count2.out | ||||
| diff ${TEST_BASE}/TEST-0009-count1.out ${TEST_BASE}/TEST-0009-count2.out | ||||
| pg_ctl stop -m immediate > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0009-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(bbalance) FROM pgbench_branches;" > ${TEST_BASE}/TEST-0009-count1.out | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT sum(delta) FROM pgbench_history;" > ${TEST_BASE}/TEST-0009-count2.out | ||||
| @@ -240,8 +240,8 @@ echo '###### recovery with target inclusive false ######' | ||||
| init_backup | ||||
| pgbench_objs 0008 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "CREATE TABLE tbl0008 (a text);" > /dev/null 2>&1 | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.out 2>&1;echo $? | ||||
| pg_arman validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -j 4 -p ${TEST_PGPORT} -d postgres --verbose > ${TEST_BASE}/TEST-0008-run.out 2>&1;echo $? | ||||
| pg_probackup validate -B ${BACKUP_PATH} --verbose >> ${TEST_BASE}/TEST-0003-run.out 2>&1 | ||||
| pgbench -p ${TEST_PGPORT} pgbench > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0008-before.out | ||||
| TARGET_XID=`psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -tAq -c "INSERT INTO tbl0008 VALUES ('inserted') RETURNING (xmin);"` | ||||
| @@ -252,7 +252,7 @@ pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c 'SELECT pg_switch_xlog()' > /dev/null 2>&1 | ||||
| # Fast mode is used to ensure that the last segment is archived as well. | ||||
| pg_ctl stop -m fast > /dev/null 2>&1 | ||||
| pg_arman restore -B ${BACKUP_PATH} --xid="${TARGET_XID}" --inclusive=false --verbose >> ${TEST_BASE}/TEST-0008-run.out 2>&1;echo $? | ||||
| pg_probackup restore -B ${BACKUP_PATH} --xid="${TARGET_XID}" --inclusive=false --verbose >> ${TEST_BASE}/TEST-0008-run.out 2>&1;echo $? | ||||
| pg_ctl start -w -t 600 > /dev/null 2>&1 | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0008-after.out | ||||
| psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM tbl0008;" > ${TEST_BASE}/TEST-0008-tbl.dump | ||||
|   | ||||
							
								
								
									
										22
									
								
								sql/show.sh
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								sql/show.sh
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| #============================================================================ | ||||
| # This is a test script for show command of pg_arman. | ||||
| # This is a test script for show command of pg_probackup. | ||||
| #============================================================================ | ||||
|  | ||||
| # Load common rules | ||||
| @@ -11,15 +11,15 @@ init_backup | ||||
|  | ||||
| echo '###### SHOW COMMAND TEST-0001 ######' | ||||
| echo '###### Status DONE and OK ######' | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $? | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001-show.out.1 2>&1 | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $? | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001-show.out.1 2>&1 | ||||
| if grep "DONE" ${TEST_BASE}/TEST-0001-show.out.1 > /dev/null ; then | ||||
|      echo 'OK: DONE status is shown properly.' | ||||
| else | ||||
|      echo 'NG: DONE status is not shown.' | ||||
| fi | ||||
| pg_arman validate -B ${BACKUP_PATH} --quiet;echo $? | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001-show.out.2 2>&1 | ||||
| pg_probackup validate -B ${BACKUP_PATH} --quiet;echo $? | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0001-show.out.2 2>&1 | ||||
| if grep "OK" ${TEST_BASE}/TEST-0001-show.out.2 > /dev/null ; then | ||||
|      echo 'OK: OK status is shown properly.' | ||||
| else | ||||
| @@ -30,9 +30,9 @@ echo '' | ||||
| echo '###### SHOW COMMAND TEST-0002 ######' | ||||
| echo '###### Status RUNNING  ######' | ||||
| init_catalog | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet & | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet & | ||||
| sleep 1 | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002-show.out 2>&1 | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0002-show.out 2>&1 | ||||
| if grep "RUNNING" ${TEST_BASE}/TEST-0002-show.out > /dev/null ; then | ||||
|      echo 'OK: RUNNING status is shown properly.' | ||||
| else | ||||
| @@ -40,7 +40,7 @@ else | ||||
| fi | ||||
| counter=0 | ||||
| # Wait for backup to finish properly before moving on to next test | ||||
| while [[ `pg_arman show -B ${BACKUP_PATH}` == *"RUNNING"* ]]; do | ||||
| while [[ `pg_probackup show -B ${BACKUP_PATH}` == *"RUNNING"* ]]; do | ||||
|      if [ $counter -gt 60 ] ; then | ||||
|           echo "Backup took too long to finish" | ||||
|           exit 1 | ||||
| @@ -53,11 +53,11 @@ echo '' | ||||
| echo '###### SHOW COMMAND TEST-0003 ######' | ||||
| echo '###### Status CORRUPT ######' | ||||
| init_catalog | ||||
| pg_arman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $? | ||||
| pg_probackup backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $? | ||||
| echo 'remove a file from backup intentionally' | ||||
| rm -f `find ${BACKUP_PATH} -name postgresql.conf` | ||||
| pg_arman validate -B ${BACKUP_PATH} --quiet > /dev/null 2>&1;echo $? | ||||
| pg_arman show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0003-show.out 2>&1 | ||||
| pg_probackup validate -B ${BACKUP_PATH} --quiet > /dev/null 2>&1;echo $? | ||||
| pg_probackup show -B ${BACKUP_PATH} > ${TEST_BASE}/TEST-0003-show.out 2>&1 | ||||
| if grep "CORRUPT" ${TEST_BASE}/TEST-0003-show.out > /dev/null ; then | ||||
|      echo 'OK: CORRUPT status is shown properly.' | ||||
| else | ||||
|   | ||||
							
								
								
									
										2
									
								
								status.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								status.c
									
									
									
									
									
								
							| @@ -16,7 +16,7 @@ | ||||
| #include <sys/types.h> | ||||
| #include <unistd.h> | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| /* PID can be negative for standalone backend */ | ||||
| typedef long pgpid_t; | ||||
|   | ||||
| @@ -21,7 +21,7 @@ yum install -y wget | ||||
| wget -k https://ftp.postgresql.org/pub/source/v$PGVERSION/postgresql-$PGVERSION.tar.gz -O postgresql.tar.gz | ||||
| tar xf postgresql.tar.gz | ||||
|  | ||||
| # install pg_arman | ||||
| # install pg_probackup | ||||
| yum install -y https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm | ||||
| yum install -y postgresql95-devel make gcc readline-devel openssl-devel pam-devel libxml2-devel libxslt-devel | ||||
| make top_srcdir=postgresql-$PGVERSION | ||||
| @@ -51,14 +51,14 @@ COUNT=$(psql -Atc "select count(*) from pgbench_accounts") | ||||
| pgbench -s $PGBENCH_SCALE -T $PGBENCH_TIME -j 2 -c 10 & | ||||
|  | ||||
| # create backup | ||||
| pg_arman init | ||||
| pg_arman backup -b full --disable-ptrack-clear --stream -v | ||||
| pg_arman show | ||||
| pg_probackup init | ||||
| pg_probackup backup -b full --disable-ptrack-clear --stream -v | ||||
| pg_probackup show | ||||
| sleep $PGBENCH_TIME | ||||
|  | ||||
| # restore from backup | ||||
| chown -R postgres:postgres $BACKUP_PATH | ||||
| su postgres -c "pg_arman restore -D $PGDATA2" | ||||
| su postgres -c "pg_probackup restore -D $PGDATA2" | ||||
|  | ||||
| # start backup server | ||||
| su postgres -c "/usr/pgsql-9.5/bin/pg_ctl stop -w -D $PGDATA" | ||||
|   | ||||
							
								
								
									
										2
									
								
								util.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								util.c
									
									
									
									
									
								
							| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <time.h> | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|  *------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #include "pg_arman.h" | ||||
| #include "pg_probackup.h" | ||||
|  | ||||
| #include <sys/stat.h> | ||||
|  | ||||
| @@ -23,11 +23,11 @@ do_validate(time_t backup_id) | ||||
| 	int		i; | ||||
| 	parray *backup_list; | ||||
| 	int ret; | ||||
| 	bool another_pg_arman = false; | ||||
| 	bool another_pg_probackup = false; | ||||
|  | ||||
| 	ret = catalog_lock(); | ||||
| 	if (ret == 1) | ||||
| 		another_pg_arman = true; | ||||
| 		another_pg_probackup = true; | ||||
|  | ||||
| 	/* get backup list matches given range */ | ||||
| 	backup_list = catalog_get_backup_list(backup_id); | ||||
| @@ -40,7 +40,7 @@ do_validate(time_t backup_id) | ||||
| 		pgBackup *backup = (pgBackup *)parray_get(backup_list, i); | ||||
|  | ||||
| 		/* clean extra backups (switch STATUS to ERROR) */ | ||||
| 		if (!another_pg_arman && | ||||
| 		if (!another_pg_probackup && | ||||
| 			(backup->status == BACKUP_STATUS_RUNNING || | ||||
| 			 backup->status == BACKUP_STATUS_DELETING)) | ||||
| 		{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user