Script to execute before rotating away the oldest backup. If it fails
backups will not be rotated.
+
+==== backup_datadir ====
+Set backup_datadir to 'no' to prevent walmgr.py from making a backup
+of the data directory when restoring to the slave. This defaults to
+'yes'
+
+
=== Sample slave.ini ===
[wal-slave]
partial_wals = %(slave)s/logs.partial
full_backup = %(slave)s/data.master
keep_backups = 5
-
+ backup_datadir = yes
If setname is specified, the contents of that backup set directory are
restored instead of "full_backup". Also copy is used instead of rename to
- restore the directory.
+ restore the directory (unless a pg_xlog directory has been specified).
Restore to altdst if specified. Complain if it exists.
"""
# nothing to back up
createbackup = False
- if not setname and os.path.isdir(data_dir):
- # compatibility mode - restore without a set name and data directory
- # already exists. Move it out of the way.
+ # see if we have to make a backup of the data directory
+ backup_datadir = self.cf.getboolean('backup_datadir', True)
+
+ if os.path.isdir(data_dir) and not backup_datadir:
+ self.log.warning('backup_datadir is disabled, deleting old data dir')
+ shutil.rmtree(data_dir)
+
+ if not setname and os.path.isdir(data_dir) and backup_datadir:
+ # compatibility mode - restore without a set name and data directory exists
self.log.warning("Data directory already exists, moving it out of the way.")
createbackup = True