pgbackrest.git / summary / log / commit / refs
commit 7bee0f3141a301c0a1fa1bb8d092dbbd317fe296
Author: David Steele <github@thelabyrinth.net>
Date: Wed Feb 05 20:56:05 2014 +0000
Moved backup location.
pg_backrest_backup.pm | 3 ++
pg_backrest_file.pm | 108 ++++++++++++++++++++++++--------------------------
2 files changed, 54 insertions(+), 57 deletions(-)
diff --git a/pg_backrest_backup.pm b/pg_backrest_backup.pm
index b6634fc19..a5057805a 100644
--- a/pg_backrest_backup.pm
+++ b/pg_backrest_backup.pm
@@ -486,6 +486,9 @@ sub backup
# confess &log(ERROR, "cluster data path '${strDbClusterPath}' does not exist");
# }
+ # Create the cluster backup path
+ path_create(PATH_BACKUP_CLUSTER);
+
# Find the previous backup based on the type
my $strBackupLastPath = backup_type_find($strType, $pg_backrest_file::strBackupClusterPath);
diff --git a/pg_backrest_file.pm b/pg_backrest_file.pm
index 25dd9bb9e..a924cdb1b 100644
--- a/pg_backrest_file.pm
+++ b/pg_backrest_file.pm
@@ -152,90 +152,84 @@ sub path_type_get
sub path_get
{
- my $strType = shift;
- my $strFile = shift;
- my $bTemp = shift;
+ my $strType = shift; # Base type of the path to get (PATH_DB_ABSOLUTE, PATH_BACKUP_TMP, etc)
+ my $strFile = shift; # File to append to the base path (can include a path as well)
+ my $bTemp = shift; # Return the temp file for this path type - only some types have temp files
+ # Only allow temp files for PATH_BACKUP_ARCHIVE and PATH_BACKUP_TMP
if (defined($bTemp) && $bTemp && !($strType eq PATH_BACKUP_ARCHIVE || $strType eq PATH_BACKUP_TMP))
{
confess &log(ASSERT, "temp file not supported on path " . $strType);
}
- # Parse paths on the db side
+ # Get absolute db path
if ($strType eq PATH_DB_ABSOLUTE)
{
return $strFile;
}
- # Parse absolute backup path
- elsif ($strType eq PATH_BACKUP_ABSOLUTE)
+
+ # Make sure the base backup path is defined
+ if (!defined($strBackupPath))
{
- return $strFile;
+ confess &log(ASSERT, "\$strBackupPath not yet defined");
}
- # Parse paths on the backup side
- elsif ($strType eq PATH_BACKUP || $strType eq PATH_BACKUP_TMP)
+
+ # Get absolute backup path
+ if ($strType eq PATH_BACKUP_ABSOLUTE)
{
- if (!defined($strBackupPath))
- {
- confess &log(ASSERT, "\$strBackupPath not yet defined");
- }
+ # Need a check in here to make sure this is relative to the backup path
- if ($strType eq PATH_BACKUP)
- {
- return $strBackupPath;
- }
+ return $strFile;
+ }
- if ($strType eq PATH_BACKUP_TMP)
- {
- if (!defined($strCluster))
- {
- confess &log(ASSERT, "\$strCluster not yet defined");
- }
+ # Get base backup path
+ if ($strType eq PATH_BACKUP)
+ {
+ return $strBackupPath . (defined($strFile) ? "/${strFile}" : "");
+ }
- my $strTempPath = "tmp/${strCluster}.tmp";
+ # Make sure the cluster is defined
+ if (!defined($strCluster))
+ {
+ confess &log(ASSERT, "\$strCluster not yet defined");
+ }
- if (defined($bTemp) && $bTemp)
- {
- return $strBackupPath . "/${strTempPath}/file.tmp";
- }
+ # Get the backup tmp path
+ if ($strType eq PATH_BACKUP_TMP)
+ {
+ my $strTempPath = "${strBackupPath}/tmp/${strCluster}.tmp";
- return $strBackupPath . "/${strTempPath}" . (defined($strFile) ? "/${strFile}" : "");
+ if (defined($bTemp) && $bTemp)
+ {
+ return "${strTempPath}/file.tmp";
}
+
+ return "${strTempPath}" . (defined($strFile) ? "/${strFile}" : "");
}
- elsif ($strType eq PATH_BACKUP_CLUSTER || $strType eq PATH_BACKUP_ARCHIVE)
+
+ # Get the backup archive path
+ if ($strType eq PATH_BACKUP_ARCHIVE)
{
- if (!defined($strBackupClusterPath))
- {
- confess &log(ASSERT, "\$strBackupClusterPath not yet defined");
- }
+ my $strArchivePath = "$strBackupPath/archive/${strCluster}";
+ my $strArchive;
- if ($strType eq PATH_BACKUP_CLUSTER)
- {
- return $strBackupClusterPath . (defined($strFile) ? "/${strFile}" : "");
- }
- elsif ($strType eq PATH_BACKUP_ARCHIVE)
+ if (defined($strFile))
{
- if (defined($bTemp) && $bTemp)
+ $strArchive = substr(basename($strFile), 0, 24);
+
+ if ($strArchive !~ /^([0-F]){24}$/)
{
- return $strBackupClusterPath . "/archive/archive.tmp";
+ return "${strArchivePath}/${strFile}";
}
- else
- {
- my $strArchive;
-
- if (defined($strFile))
- {
- $strArchive = substr(basename($strFile), 0, 24);
+ }
- if ($strArchive !~ /^([0-F]){24}$/)
- {
- return $strBackupClusterPath . "/archive/${strFile}";
- }
- }
+ return $strArchivePath . (defined($strArchive) ? "/" . substr($strArchive, 0, 16) : "") .
+ (defined($strFile) ? "/" . $strFile : "");
+ }
- return $strBackupClusterPath . "/archive" . (defined($strArchive) ? "/" .
- substr($strArchive, 0, 16) : "") . (defined($strFile) ? "/" . $strFile : "");
- }
- }
+ if ($strType eq PATH_BACKUP_CLUSTER)
+ {
+ return $strBackupPath . "/backup/${strCluster}" . (defined($strFile) ? "/${strFile}" : "");
}
# Error when path type not recognized
[parent: a15fcb8c23e1]