diff options
author | Martin Pihlak | 2010-07-27 07:54:24 +0000 |
---|---|---|
committer | Martin Pihlak | 2010-07-27 07:57:22 +0000 |
commit | 1cc37e1ac88c7f932fce59dbdaa8d98e1d139a59 (patch) | |
tree | 218cf07a8b6f0818cce27860ea27cd6ab1e74f04 /python/walmgr.py | |
parent | deae6234708d6a05beb1c5dc783d2622129b7c3a (diff) |
Introduce a 'backup_datadir' configuration variable to
control whether the slave data directory is kept or
overwritten during restore. Patch from Steve Singer.
Diffstat (limited to 'python/walmgr.py')
-rwxr-xr-x | python/walmgr.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/python/walmgr.py b/python/walmgr.py index d880ef87..81a2e0b1 100755 --- a/python/walmgr.py +++ b/python/walmgr.py @@ -1246,7 +1246,7 @@ STOP TIME: %(stop_time)s 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. """ @@ -1305,9 +1305,15 @@ STOP TIME: %(stop_time)s # 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 |