Skip to content

Commit 78362a5

Browse files
committed
Move all backups to "backups" subdir.
1 parent bd01446 commit 78362a5

File tree

5 files changed

+15
-27
lines changed

5 files changed

+15
-27
lines changed

catalog.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@ catalog_get_backup_list(time_t backup_id)
111111
DIR *date_dir = NULL;
112112
struct dirent *date_ent = NULL;
113113
DIR *time_dir = NULL;
114+
char backups_path[MAXPGPATH];
114115
char date_path[MAXPGPATH];
115116
parray *backups = NULL;
116117
pgBackup *backup = NULL;
117118

118119
/* open backup root directory */
119-
date_dir = opendir(backup_path);
120+
join_path_components(backups_path, backup_path, BACKUPS_DIR);
121+
date_dir = opendir(backups_path);
120122
if (date_dir == NULL)
121123
{
122-
elog(WARNING, "cannot open directory \"%s\": %s", backup_path,
124+
elog(WARNING, "cannot open directory \"%s\": %s", backups_path,
123125
strerror(errno));
124126
goto err_proc;
125127
}
@@ -131,15 +133,11 @@ catalog_get_backup_list(time_t backup_id)
131133
char ini_path[MAXPGPATH];
132134

133135
/* skip not-directory entries and hidden entries */
134-
if (!IsDir(backup_path, date_ent->d_name) || date_ent->d_name[0] == '.')
135-
continue;
136-
137-
/* skip online WAL backup directory */
138-
if (strcmp(date_ent->d_name, RESTORE_WORK_DIR) == 0)
136+
if (!IsDir(backups_path, date_ent->d_name) || date_ent->d_name[0] == '.')
139137
continue;
140138

141139
/* open subdirectory (date directory) and search time directory */
142-
join_path_components(date_path, backup_path, date_ent->d_name);
140+
join_path_components(date_path, backups_path, date_ent->d_name);
143141

144142
/* read backup information from backup.ini */
145143
snprintf(ini_path, MAXPGPATH, "%s/%s", date_path, BACKUP_INI_FILE);
@@ -166,7 +164,7 @@ catalog_get_backup_list(time_t backup_id)
166164
if (errno)
167165
{
168166
elog(WARNING, "cannot read backup root directory \"%s\": %s",
169-
backup_path, strerror(errno));
167+
backups_path, strerror(errno));
170168
goto err_proc;
171169
}
172170

@@ -492,9 +490,9 @@ pgBackupGetPath(const pgBackup *backup, char *path, size_t len, const char *subd
492490

493491
datetime = base36enc(backup->start_time);
494492
if (subdir)
495-
snprintf(path, len, "%s/%s/%s", backup_path, datetime, subdir);
493+
snprintf(path, len, "%s/%s/%s/%s", backup_path, BACKUPS_DIR, datetime, subdir);
496494
else
497-
snprintf(path, len, "%s/%s", backup_path, datetime);
495+
snprintf(path, len, "%s/%s/%s", backup_path, BACKUPS_DIR, datetime);
498496
free(datetime);
499497
}
500498

expected/init.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
###### success with archive_command ######
44
0
55
results/init/backup/
6-
results/init/backup/backup/
6+
results/init/backup/backups/
77
results/init/backup/pg_arman.ini
88
results/init/backup/wal/
99
###### INIT COMMAND TEST-0002 ######
1010
###### success with archive_command and log_directory ######
1111
0
1212
results/init/backup/
13-
results/init/backup/backup/
13+
results/init/backup/backups/
1414
results/init/backup/pg_arman.ini
1515
results/init/backup/wal/
1616
###### INIT COMMAND TEST-0003 ######
1717
###### success without archive_command ######
1818
0
1919
results/init/backup/
20-
results/init/backup/backup/
20+
results/init/backup/backups/
2121
results/init/backup/pg_arman.ini
2222
results/init/backup/wal/
2323
###### INIT COMMAND TEST-0004 ######

init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ do_init(void)
4848
dir_create_dir(backup_path, DIR_PERMISSION);
4949

5050
/* create directories for backup of online files */
51-
join_path_components(path, backup_path, RESTORE_WORK_DIR);
51+
join_path_components(path, backup_path, BACKUPS_DIR);
5252
dir_create_dir(path, DIR_PERMISSION);
5353

5454
/* read postgresql.conf */

pg_arman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
/* Directory/File names */
3333
#define DATABASE_DIR "database"
34-
#define RESTORE_WORK_DIR "backup"
34+
#define BACKUPS_DIR "backups"
3535
#define PG_XLOG_DIR "pg_xlog"
3636
#define PG_TBLSPC_DIR "pg_tblspc"
3737
#define BACKUP_INI_FILE "backup.ini"

restore.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -514,23 +514,13 @@ readTimeLineHistory(TimeLineID targetTLI)
514514
/* search from arclog_path first */
515515
snprintf(path, lengthof(path), "%s/%08X.history", arclog_path,
516516
targetTLI);
517+
517518
fd = fopen(path, "rt");
518519
if (fd == NULL)
519520
{
520521
if (errno != ENOENT)
521522
elog(ERROR, "could not open file \"%s\": %s", path,
522523
strerror(errno));
523-
524-
/* search from restore work directory next */
525-
snprintf(path, lengthof(path), "%s/%s/%s/%08X.history", backup_path,
526-
RESTORE_WORK_DIR, PG_XLOG_DIR, targetTLI);
527-
fd = fopen(path, "rt");
528-
if (fd == NULL)
529-
{
530-
if (errno != ENOENT)
531-
elog(ERROR, "could not open file \"%s\": %s", path,
532-
strerror(errno));
533-
}
534524
}
535525

536526
/*

0 commit comments

Comments
 (0)