1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-05-27 22:37:55 +02:00

Fix issue #137: Info command throws an exception if no stanzas exist.

This commit is contained in:
David Steele 2015-09-08 16:44:47 -04:00
parent 8d01138f6d
commit 59b2261a8e
10 changed files with 208 additions and 2 deletions

View File

@ -156,7 +156,14 @@ sub process
}
}
syswrite(*STDOUT, $strOutput);
if (defined($strOutput))
{
syswrite(*STDOUT, $strOutput);
}
else
{
syswrite(*STDOUT, 'No stanzas exist in ' . $oFile->pathGet(PATH_BACKUP) . ".\n");
}
}
elsif (optionTest(OPTION_OUTPUT, INFO_OUTPUT_JSON))
{

View File

@ -1067,7 +1067,7 @@ sub BackRestTestBackup_Test
undef, undef, undef, undef, undef, undef,
'no tablespace remap', undef, '--no-tablespace', false);
# Backup Info
# Backup Info (with an empty stanza)
#-----------------------------------------------------------------------------------------------------------------------
BackRestTestCommon_Execute('mkdir ' . BackRestTestCommon_RepoPathGet . '/backup/db_empty', $bRemote);
@ -1075,6 +1075,13 @@ sub BackRestTestBackup_Test
BackRestTestBackup_Info(undef, INFO_OUTPUT_JSON, false);
BackRestTestBackup_Info('bogus', undef, false);
BackRestTestBackup_Info('bogus', INFO_OUTPUT_JSON, false);
# Backup Info (with no stanzas)
#-----------------------------------------------------------------------------------------------------------------------
BackRestTestCommon_Execute('rm -rf ' . BackRestTestCommon_RepoPathGet . '/backup/*', $bRemote);
BackRestTestBackup_Info(undef, undef, false);
BackRestTestBackup_Info(undef, INFO_OUTPUT_JSON, false);
}
}
}

View File

@ -3277,3 +3277,27 @@ DEBUG: File->list=>: stryFileList = (db, db_empty)
]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --log-level-console=debug --log-level-file=trace --repo-path=[TEST_PATH]/backrest --repo-remote-path=[TEST_PATH]/backrest
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = none, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
DEBUG: File->list(): bIgnoreMissing = true, strExpression = [undef], strPath = backup, strPathType = backup, strSortOrder = <forward>
DEBUG: File->list=>: stryFileList = ()
No stanzas exist in [TEST_PATH]/backrest.
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info --output=json
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --log-level-console=debug --log-level-file=trace --output=json --repo-path=[TEST_PATH]/backrest --repo-remote-path=[TEST_PATH]/backrest
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = none, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
DEBUG: File->list(): bIgnoreMissing = true, strExpression = [undef], strPath = backup, strPathType = backup, strSortOrder = <forward>
DEBUG: File->list=>: stryFileList = ()
[]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop

View File

@ -3423,3 +3423,27 @@ DEBUG: File->list=>: stryFileList = (db, db_empty)
]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --log-level-console=debug --log-level-file=trace --repo-path=[TEST_PATH]/backrest --repo-remote-path=[TEST_PATH]/backrest
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = none, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
DEBUG: File->list(): bIgnoreMissing = true, strExpression = [undef], strPath = backup, strPathType = backup, strSortOrder = <forward>
DEBUG: File->list=>: stryFileList = ()
No stanzas exist in [TEST_PATH]/backrest.
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info --output=json
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --log-level-console=debug --log-level-file=trace --output=json --repo-path=[TEST_PATH]/backrest --repo-remote-path=[TEST_PATH]/backrest
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = none, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
DEBUG: File->list(): bIgnoreMissing = true, strExpression = [undef], strPath = backup, strPathType = backup, strSortOrder = <forward>
DEBUG: File->list=>: stryFileList = ()
[]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop

View File

@ -3264,3 +3264,27 @@ DEBUG: File->list=>: stryFileList = (db, db_empty)
]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --log-level-console=debug --log-level-file=trace --repo-path=[TEST_PATH]/backrest --repo-remote-path=[TEST_PATH]/backrest
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = none, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
DEBUG: File->list(): bIgnoreMissing = true, strExpression = [undef], strPath = backup, strPathType = backup, strSortOrder = <forward>
DEBUG: File->list=>: stryFileList = ()
No stanzas exist in [TEST_PATH]/backrest.
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info --output=json
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --log-level-console=debug --log-level-file=trace --output=json --repo-path=[TEST_PATH]/backrest --repo-remote-path=[TEST_PATH]/backrest
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = none, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
DEBUG: File->list(): bIgnoreMissing = true, strExpression = [undef], strPath = backup, strPathType = backup, strSortOrder = <forward>
DEBUG: File->list=>: stryFileList = ()
[]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop

View File

@ -3410,3 +3410,27 @@ DEBUG: File->list=>: stryFileList = (db, db_empty)
]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --log-level-console=debug --log-level-file=trace --repo-path=[TEST_PATH]/backrest --repo-remote-path=[TEST_PATH]/backrest
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = none, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
DEBUG: File->list(): bIgnoreMissing = true, strExpression = [undef], strPath = backup, strPathType = backup, strSortOrder = <forward>
DEBUG: File->list=>: stryFileList = ()
No stanzas exist in [TEST_PATH]/backrest.
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info --output=json
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --log-level-console=debug --log-level-file=trace --output=json --repo-path=[TEST_PATH]/backrest --repo-remote-path=[TEST_PATH]/backrest
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = none, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
DEBUG: File->list(): bIgnoreMissing = true, strExpression = [undef], strPath = backup, strPathType = backup, strSortOrder = <forward>
DEBUG: File->list=>: stryFileList = ()
[]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop

View File

@ -3619,3 +3619,27 @@ DEBUG: Info->stanzaList(): oFile = [object], strStanza = bogus
]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --backup-host=127.0.0.1 --backup-user=backrest --cmd-remote=[BACKREST_BIN] --log-level-console=debug --log-level-file=trace --repo-path=[TEST_PATH]/local --repo-remote-path=[TEST_PATH]/backrest
DEBUG: Protocol::RemoteMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = [BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote, strHost = 127.0.0.1, strUser = [USER-2]
DEBUG: Protocol::CommonMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = ssh -o Compression=no -o PasswordAuthentication=no backrest@127.0.0.1 '[BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote', strName = remote
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = backup, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
No stanzas exist in [TEST_PATH]/backrest.
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info --output=json
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --backup-host=127.0.0.1 --backup-user=backrest --cmd-remote=[BACKREST_BIN] --log-level-console=debug --log-level-file=trace --output=json --repo-path=[TEST_PATH]/local --repo-remote-path=[TEST_PATH]/backrest
DEBUG: Protocol::RemoteMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = [BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote, strHost = 127.0.0.1, strUser = [USER-2]
DEBUG: Protocol::CommonMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = ssh -o Compression=no -o PasswordAuthentication=no backrest@127.0.0.1 '[BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote', strName = remote
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = backup, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
[]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop

View File

@ -3765,3 +3765,27 @@ DEBUG: Info->stanzaList(): oFile = [object], strStanza = bogus
]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --backup-host=127.0.0.1 --backup-user=backrest --cmd-remote=[BACKREST_BIN] --log-level-console=debug --log-level-file=trace --repo-path=[TEST_PATH]/local --repo-remote-path=[TEST_PATH]/backrest
DEBUG: Protocol::RemoteMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = [BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote, strHost = 127.0.0.1, strUser = [USER-2]
DEBUG: Protocol::CommonMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = ssh -o Compression=no -o PasswordAuthentication=no backrest@127.0.0.1 '[BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote', strName = remote
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = backup, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
No stanzas exist in [TEST_PATH]/backrest.
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info --output=json
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --backup-host=127.0.0.1 --backup-user=backrest --cmd-remote=[BACKREST_BIN] --log-level-console=debug --log-level-file=trace --output=json --repo-path=[TEST_PATH]/local --repo-remote-path=[TEST_PATH]/backrest
DEBUG: Protocol::RemoteMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = [BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote, strHost = 127.0.0.1, strUser = [USER-2]
DEBUG: Protocol::CommonMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = ssh -o Compression=no -o PasswordAuthentication=no backrest@127.0.0.1 '[BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote', strName = remote
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = backup, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
[]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop

View File

@ -3593,3 +3593,27 @@ DEBUG: Info->stanzaList(): oFile = [object], strStanza = bogus
]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --backup-host=127.0.0.1 --backup-user=backrest --cmd-remote=[BACKREST_BIN] --log-level-console=debug --log-level-file=trace --repo-path=[TEST_PATH]/local --repo-remote-path=[TEST_PATH]/backrest
DEBUG: Protocol::RemoteMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = [BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote, strHost = 127.0.0.1, strUser = [USER-2]
DEBUG: Protocol::CommonMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = ssh -o Compression=no -o PasswordAuthentication=no backrest@127.0.0.1 '[BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote', strName = remote
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = backup, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
No stanzas exist in [TEST_PATH]/backrest.
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info --output=json
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --backup-host=127.0.0.1 --backup-user=backrest --cmd-remote=[BACKREST_BIN] --log-level-console=debug --log-level-file=trace --output=json --repo-path=[TEST_PATH]/local --repo-remote-path=[TEST_PATH]/backrest
DEBUG: Protocol::RemoteMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = [BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote, strHost = 127.0.0.1, strUser = [USER-2]
DEBUG: Protocol::CommonMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = ssh -o Compression=no -o PasswordAuthentication=no backrest@127.0.0.1 '[BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote', strName = remote
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = backup, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
[]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop

View File

@ -3739,3 +3739,27 @@ DEBUG: Info->stanzaList(): oFile = [object], strStanza = bogus
]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --backup-host=127.0.0.1 --backup-user=backrest --cmd-remote=[BACKREST_BIN] --log-level-console=debug --log-level-file=trace --repo-path=[TEST_PATH]/local --repo-remote-path=[TEST_PATH]/backrest
DEBUG: Protocol::RemoteMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = [BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote, strHost = 127.0.0.1, strUser = [USER-2]
DEBUG: Protocol::CommonMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = ssh -o Compression=no -o PasswordAuthentication=no backrest@127.0.0.1 '[BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote', strName = remote
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = backup, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
No stanzas exist in [TEST_PATH]/backrest.
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop
info
> [BACKREST_BIN] --config=[TEST_PATH]/db/pg_backrest.conf info --output=json
------------------------------------------------------------------------------------------------------------------------------------
DEBUG: info start: --backup-host=127.0.0.1 --backup-user=backrest --cmd-remote=[BACKREST_BIN] --log-level-console=debug --log-level-file=trace --output=json --repo-path=[TEST_PATH]/local --repo-remote-path=[TEST_PATH]/backrest
DEBUG: Protocol::RemoteMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = [BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote, strHost = 127.0.0.1, strUser = [USER-2]
DEBUG: Protocol::CommonMaster->new(): iBlockSize = 4194304, iCompressLevel = 6, iCompressLevelNetwork = 3, strCommand = ssh -o Compression=no -o PasswordAuthentication=no backrest@127.0.0.1 '[BACKREST_BIN] --no-config --repo-remote-path=[TEST_PATH]/backrest remote', strName = remote
DEBUG: File->new(): iThreadIdx = [undef], oProtocol = [object], strBackupPath = [TEST_PATH]/backrest, strDefaultFileMode = <0640>, strDefaultPathMode = <0750>, strRemote = backup, strStanza = [undef]
DEBUG: Info->stanzaList(): oFile = [object], strStanza = [undef]
[]
DEBUG: Main::safeExit(): iExitCode = 0
DEBUG: info stop