Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitea89ca3

Browse files
author
Michael Paquier
committed
Remove remaining LVM-snapshot logic
Extracted from a patch by Yury Zhuravlev, and visibly this portion wasmissed in last cleanup that occurred inb92d722.
1 parente2bbf69 commitea89ca3

File tree

2 files changed

+9
-238
lines changed

2 files changed

+9
-238
lines changed

‎backup.c

Lines changed: 9 additions & 229 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
staticintserver_version=0;
2828

2929
staticboolin_backup= false;/* TODO: more robust logic */
30-
/* List of commands to execute at error processing for snapshot */
31-
staticparray*cleanup_list;
3230

3331
/*
3432
* Backup routines
@@ -44,10 +42,7 @@ static bool pg_is_standby(void);
4442
staticvoidget_lsn(PGresult*res,XLogRecPtr*lsn);
4543
staticvoidget_xid(PGresult*res,uint32*xid);
4644

47-
staticbooldirExists(constchar*path);
48-
4945
staticvoidadd_files(parray*files,constchar*root,booladd_root,boolis_pgdata);
50-
staticintstrCompare(constvoid*str1,constvoid*str2);
5146
staticvoidcreate_file_list(parray*files,
5247
constchar*root,
5348
constchar*subdir,
@@ -174,209 +169,19 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
174169

175170
/* initialize backup list from non-snapshot */
176171
files=parray_new();
177-
join_path_components(path,backup_path,SNAPSHOT_SCRIPT_FILE);
178-
179-
/*
180-
* Check the existence of the snapshot-script.
181-
* backup use snapshot when snapshot-script exists.
182-
*/
183-
if (fileExists(path))
184-
{
185-
parray*tblspc_list;/* list of name of TABLESPACE backup from snapshot */
186-
parray*tblspcmp_list;/* list of mounted directory of TABLESPACE in snapshot volume */
187-
PGresult*tblspc_res;/* contain spcname and oid in TABLESPACE */
188-
189-
tblspc_list=parray_new();
190-
tblspcmp_list=parray_new();
191-
cleanup_list=parray_new();
192-
193-
/*
194-
* append 'pg_tblspc' to list of directory excluded from copy.
195-
* because DB cluster and TABLESPACE are copied separately.
196-
*/
197-
for (i=0;pgdata_exclude[i];i++);/* find first empty slot */
198-
pgdata_exclude[i]=PG_TBLSPC_DIR;
199-
200-
/*
201-
* when DB cluster is not contained in the backup from the snapshot,
202-
* DB cluster is added to the backup file list from non-snapshot.
203-
*/
204-
parray_qsort(tblspc_list,strCompare);
205-
if (parray_bsearch(tblspc_list,"PG-DATA",strCompare)==NULL)
206-
add_files(files,pgdata, false, true);
207-
else
208-
/* remove the detected tablespace("PG-DATA") from tblspc_list */
209-
parray_rm(tblspc_list,"PG-DATA",strCompare);
210-
211-
/*
212-
* select the TABLESPACE backup from non-snapshot,
213-
* and append TABLESPACE to the list backup from non-snapshot.
214-
* TABLESPACE name and oid is obtained by inquiring of the database.
215-
*/
216-
217-
reconnect();
218-
tblspc_res=execute("SELECT spcname, oid FROM pg_tablespace WHERE "
219-
"spcname NOT IN ('pg_default', 'pg_global') ORDER BY spcname ASC",0,NULL);
220-
disconnect();
221-
for (i=0;i<PQntuples(tblspc_res);i++)
222-
{
223-
char*name=PQgetvalue(tblspc_res,i,0);
224-
char*oid=PQgetvalue(tblspc_res,i,1);
225-
226-
/* when not found, append it to the backup list from non-snapshot */
227-
if (parray_bsearch(tblspc_list,name,strCompare)==NULL)
228-
{
229-
chardir[MAXPGPATH];
230-
join_path_components(dir,pgdata,PG_TBLSPC_DIR);
231-
join_path_components(dir,dir,oid);
232-
add_files(files,dir, true, false);
233-
}
234-
else
235-
/* remove the detected tablespace from tblspc_list */
236-
parray_rm(tblspc_list,name,strCompare);
237-
}
238-
239-
/*
240-
* tblspc_list is not empty,
241-
* so snapshot-script output the tablespace name that not exist.
242-
*/
243-
if (parray_num(tblspc_list)>0)
244-
elog(ERROR_SYSTEM,"snapshot-script output the name of tablespace that not exist");
245-
246-
/* clear array */
247-
parray_walk(tblspc_list,free);
248-
parray_free(tblspc_list);
249-
250-
/* backup files from non-snapshot */
251-
pgBackupGetPath(&current,path,lengthof(path),DATABASE_DIR);
252-
backup_files(pgdata,path,files,prev_files,lsn,NULL);
253-
254-
/* notify end of backup */
255-
pg_stop_backup(&current);
256-
257-
/* create file list of non-snapshot objects */
258-
create_file_list(files,pgdata,DATABASE_FILE_LIST,NULL, false);
259172

260-
/* backup files from snapshot volume */
261-
for (i=0;i<parray_num(tblspcmp_list);i++)
262-
{
263-
char*spcname;
264-
char*mp=NULL;
265-
char*item= (char*)parray_get(tblspcmp_list,i);
266-
parray*snapshot_files=parray_new();
267-
268-
/*
269-
* obtain the TABLESPACE name and the directory where it is stored.
270-
* Note: strtok() replace the delimiter to '\0'. but no problem because
271-
* it doesn't use former value
272-
*/
273-
if ((spcname=strtok(item,"="))==NULL|| (mp=strtok(NULL,"\0"))==NULL)
274-
elog(ERROR_SYSTEM,"snapshot-script output illegal format: %s",item);
275-
276-
elog(LOG,"========================================");
277-
elog(LOG,"backup files from snapshot: \"%s\"",spcname);
278-
279-
/* tablespace storage directory not exist */
280-
if (!dirExists(mp))
281-
elog(ERROR_SYSTEM,"tablespace storage directory doesn't exist: %s",mp);
282-
283-
/*
284-
* create the previous backup file list to take differential backup
285-
* from the snapshot volume.
286-
*/
287-
if (prev_files!=NULL)
288-
prev_files=dir_read_file_list(mp,prev_file_txt);
289-
290-
/* when DB cluster is backup from snapshot, it backup from the snapshot */
291-
if (strcmp(spcname,"PG-DATA")==0)
292-
{
293-
/* append DB cluster to backup file list */
294-
add_files(snapshot_files,mp, false, true);
295-
/* backup files of DB cluster from snapshot volume */
296-
backup_files(mp,path,snapshot_files,prev_files,lsn,NULL);
297-
/* create file list of snapshot objects (DB cluster) */
298-
create_file_list(snapshot_files,mp,DATABASE_FILE_LIST,
299-
NULL, true);
300-
/* remove the detected tablespace("PG-DATA") from tblspcmp_list */
301-
parray_rm(tblspcmp_list,"PG-DATA",strCompare);
302-
i--;
303-
}
304-
/* backup TABLESPACE from snapshot volume */
305-
else
306-
{
307-
intj;
308-
309-
/*
310-
* obtain the oid from TABLESPACE information acquired by inquiring of database.
311-
* and do backup files of TABLESPACE from snapshot volume.
312-
*/
313-
for (j=0;j<PQntuples(tblspc_res);j++)
314-
{
315-
chardest[MAXPGPATH];
316-
charprefix[MAXPGPATH];
317-
char*name=PQgetvalue(tblspc_res,j,0);
318-
char*oid=PQgetvalue(tblspc_res,j,1);
319-
320-
if (strcmp(spcname,name)==0)
321-
{
322-
/* append TABLESPACE to backup file list */
323-
add_files(snapshot_files,mp, true, false);
324-
325-
/* backup files of TABLESPACE from snapshot volume */
326-
join_path_components(prefix,PG_TBLSPC_DIR,oid);
327-
join_path_components(dest,path,prefix);
328-
backup_files(mp,dest,snapshot_files,prev_files,lsn,prefix);
329-
330-
/* create file list of snapshot objects (TABLESPACE) */
331-
create_file_list(snapshot_files,mp,DATABASE_FILE_LIST,
332-
prefix, true);
333-
/*
334-
* Remove the detected tablespace("PG-DATA") from
335-
* tblspcmp_list.
336-
*/
337-
parray_rm(tblspcmp_list,spcname,strCompare);
338-
i--;
339-
break;
340-
}
341-
}
342-
}
343-
parray_concat(files,snapshot_files);
344-
}
345-
346-
/*
347-
* tblspcmp_list is not empty,
348-
* so snapshot-script output the tablespace name that not exist.
349-
*/
350-
if (parray_num(tblspcmp_list)>0)
351-
elog(ERROR_SYSTEM,"snapshot-script output the name of tablespace that not exist");
352-
353-
/* clear array */
354-
parray_walk(tblspcmp_list,free);
355-
parray_free(tblspcmp_list);
356-
357-
358-
/* don't use 'parray_walk'. element of parray not allocate memory by malloc */
359-
parray_free(cleanup_list);
360-
PQclear(tblspc_res);
361-
}
362-
/* when snapshot-script not exist, DB cluster and TABLESPACE are backup
363-
* at same time.
364-
*/
365-
else
366-
{
367-
/* list files with the logical path. omit $PGDATA */
368-
add_files(files,pgdata, false, true);
173+
/* list files with the logical path. omit $PGDATA */
174+
add_files(files,pgdata, false, true);
369175

370-
/* backup files */
371-
pgBackupGetPath(&current,path,lengthof(path),DATABASE_DIR);
372-
backup_files(pgdata,path,files,prev_files,lsn,NULL);
176+
/* backup files */
177+
pgBackupGetPath(&current,path,lengthof(path),DATABASE_DIR);
178+
backup_files(pgdata,path,files,prev_files,lsn,NULL);
373179

374-
/* notify end of backup */
375-
pg_stop_backup(&current);
180+
/* notify end of backup */
181+
pg_stop_backup(&current);
376182

377-
/* create file list */
378-
create_file_list(files,pgdata,DATABASE_FILE_LIST,NULL, false);
379-
}
183+
/* create file list */
184+
create_file_list(files,pgdata,DATABASE_FILE_LIST,NULL, false);
380185

381186
/* print summary of size of backup mode files */
382187
for (i=0;i<parray_num(files);i++)
@@ -750,22 +555,6 @@ fileExists(const char *path)
750555
return true;
751556
}
752557

753-
/*
754-
* Return true if the path is a existing directory.
755-
*/
756-
staticbool
757-
dirExists(constchar*path)
758-
{
759-
structstatbuf;
760-
761-
if (stat(path,&buf)==-1&&errno==ENOENT)
762-
return false;
763-
elseif (S_ISREG(buf.st_mode))
764-
return false;
765-
else
766-
return true;
767-
}
768-
769558
/*
770559
* Notify end of backup to server when "backup_label" is in the root directory
771560
* of the DB cluster.
@@ -1011,15 +800,6 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
1011800
parray_concat(files,list_file);
1012801
}
1013802

1014-
/*
1015-
* Comparison function for parray_bsearch() compare the character string.
1016-
*/
1017-
staticint
1018-
strCompare(constvoid*str1,constvoid*str2)
1019-
{
1020-
returnstrcmp(*(char**)str1,*(char**)str2);
1021-
}
1022-
1023803
/*
1024804
* Output the list of files to backup catalog
1025805
*/

‎pg_arman.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,9 @@
3232
#definePG_RMAN_INI_FILE"pg_arman.ini"
3333
#defineMKDIRS_SH_FILE"mkdirs.sh"
3434
#defineDATABASE_FILE_LIST"file_database.txt"
35-
#defineSNAPSHOT_SCRIPT_FILE"snapshot_script"
3635
#definePG_BACKUP_LABEL_FILE"backup_label"
3736
#definePG_BLACK_LIST"black_list"
3837

39-
/* Snapshot script command */
40-
#defineSNAPSHOT_FREEZE"freeze"
41-
#defineSNAPSHOT_UNFREEZE"unfreeze"
42-
#defineSNAPSHOT_SPLIT"split"
43-
#defineSNAPSHOT_RESYNC"resync"
44-
#defineSNAPSHOT_MOUNT"mount"
45-
#defineSNAPSHOT_UMOUNT"umount"
46-
4738
/* Direcotry/File permission */
4839
#defineDIR_PERMISSION(0700)
4940
#defineFILE_PERMISSION(0600)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp