From be1163b948200c409199302ab5c03e724c7b7331 Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 1 Apr 2014 10:49:37 -0400 Subject: [PATCH] v0.16: RequestTTY=yes for SSH sessions * Added RequestTTY=yes to ssh sesssions. Hoping this will prevent random lockups. --- README.md | 27 ++++++++++++++------------- pg_backrest.pl | 1 + pg_backrest_backup.pm | 4 ++++ pg_backrest_db.pm | 5 ++++- pg_backrest_file.pm | 11 +++++++---- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 73b9c0cfe..35453c9de 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,30 @@ -pg_backrest -=========== +# pg_backrest Simple Postgres Backup and Restore -planned for next release -======================== +## planned for next release * Default restore.conf is written to each backup. * Able to set timeout on ssh connection in config file. -release notes -============= +* Fix bug where .backup files written into old directories can cause the archive process to error. -v0.15: Added archive-get +* Add configurable sleep to archiver process to reduce ssh connections. + +## release notes + +### v0.16: RequestTTY=yes for SSH sessions + +* Added RequestTTY=yes to ssh sesssions. Hoping this will prevent random lockups. + +### v0.15: Added archive-get * Added archive-get functionality to aid in restores. * Added option to force a checkpoint when starting the backup (start_fast=y). -------------- - -v0.11: Minor fixes +### v0.11: Minor fixes Tweaking a few settings after running backups for about a month. @@ -29,9 +32,7 @@ Tweaking a few settings after running backups for about a month. * Changed lock file conflicts on backup and expire commands to ERROR. They were set to DEBUG due to a copy-and-paste from the archive locks. -------------- - -v0.10: Backup and archiving are functional +### v0.10: Backup and archiving are functional This version has been put into production at Resonate, so it does work, but there are a number of major caveats. diff --git a/pg_backrest.pl b/pg_backrest.pl index ad7078766..1e537ace9 100755 --- a/pg_backrest.pl +++ b/pg_backrest.pl @@ -401,6 +401,7 @@ if ($strOperation eq OP_ARCHIVE_PUSH || $strOperation eq OP_ARCHIVE_PULL) # Call the archive_pull function Continue to loop as long as there are files to process. while (archive_pull($strArchivePath . "/archive/${strStanza}", $strStopFile, $strCommand, $iArchiveMaxMB)) { + &log(DEBUG, "archive logs were transferred, calling archive_pull() again"); } }; diff --git a/pg_backrest_backup.pm b/pg_backrest_backup.pm index c5a0eed97..5aab47ca8 100644 --- a/pg_backrest_backup.pm +++ b/pg_backrest_backup.pm @@ -362,6 +362,10 @@ sub archive_pull &log(DEBUG, "removing local archive path ${strPath}"); rmdir($strArchivePath . "/" . $strPath) or confess &log(ERROR, "unable to remove archive path ${strPath}, is it empty?"); } + + # If the dir is not empty check if the files are in the manifest + # If they are error - there has been some issue + # If not, they are new - continue processing without error - they'll be picked up on the next run } # Return number of files indicating that processing should continue diff --git a/pg_backrest_db.pm b/pg_backrest_db.pm index 6f1ccb73a..9d5e3d0ab 100644 --- a/pg_backrest_db.pm +++ b/pg_backrest_db.pm @@ -35,10 +35,13 @@ sub BUILD # Connect SSH object if db host is defined if (defined($self->{strDbHost}) && !defined($self->{oDbSSH})) { + my $strOptionSSHRequestTTY = "RequestTTY=yes"; + &log(TRACE, "connecting to database ssh host $self->{strDbHost}"); # !!! This could be improved by redirecting stderr to a file to get a better error message - $self->{oDbSSH} = Net::OpenSSH->new($self->{strDbHost}, user => $self->{strDbUser}); + $self->{oDbSSH} = Net::OpenSSH->new($self->{strDbHost}, user => $self->{strDbUser}, + master_opts => [-o => $strOptionSSHRequestTTY]); $self->{oDbSSH}->error and confess &log(ERROR, "unable to connect to $self->{strDbHost}: " . $self->{oDbSSH}->error); } } diff --git a/pg_backrest_file.pm b/pg_backrest_file.pm index f1bfab11e..398143148 100644 --- a/pg_backrest_file.pm +++ b/pg_backrest_file.pm @@ -67,11 +67,12 @@ sub BUILD # Create the ssh options string if (defined($self->{strBackupHost}) || defined($self->{strDbHost})) { - my $strOptionSSH = "Compression=no"; + my $strOptionSSHRequestTTY = "RequestTTY=yes"; + my $strOptionSSHCompression = "Compression=no"; if ($self->{bNoCompression}) { - $strOptionSSH = "Compression=yes"; + $strOptionSSHCompression = "Compression=yes"; } # Connect SSH object if backup host is defined @@ -80,7 +81,8 @@ sub BUILD &log(TRACE, "connecting to backup ssh host " . $self->{strBackupHost}); # !!! This could be improved by redirecting stderr to a file to get a better error message - $self->{oBackupSSH} = Net::OpenSSH->new($self->{strBackupHost}, timeout => 300, user => $self->{strBackupUser}, master_opts => [-o => $strOptionSSH]); + $self->{oBackupSSH} = Net::OpenSSH->new($self->{strBackupHost}, timeout => 300, user => $self->{strBackupUser}, + master_opts => [-o => $strOptionSSHCompression, -o => $strOptionSSHRequestTTY]); $self->{oBackupSSH}->error and confess &log(ERROR, "unable to connect to $self->{strBackupHost}: " . $self->{oBackupSSH}->error); } @@ -90,7 +92,8 @@ sub BUILD &log(TRACE, "connecting to database ssh host $self->{strDbHost}"); # !!! This could be improved by redirecting stderr to a file to get a better error message - $self->{oDbSSH} = Net::OpenSSH->new($self->{strDbHost}, timeout => 300, user => $self->{strDbUser}, master_opts => [-o => $strOptionSSH]); + $self->{oDbSSH} = Net::OpenSSH->new($self->{strDbHost}, timeout => 300, user => $self->{strDbUser}, + master_opts => [-o => $strOptionSSHCompression, -o => $strOptionSSHRequestTTY]); $self->{oDbSSH}->error and confess &log(ERROR, "unable to connect to $self->{strDbHost}: " . $self->{oDbSSH}->error); } }