@@ -497,7 +497,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
497
497
}
498
498
499
499
/* cleanup */
500
- parray_walk (backups , pgBackupFree ); /* TODO: free backup->files */
500
+ parray_walk (backups , pgBackupFree );
501
501
parray_free (backups );
502
502
parray_free (parent_chain );
503
503
@@ -529,29 +529,19 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
529
529
530
530
/* Preparations for actual restoring */
531
531
time2iso (timestamp , lengthof (timestamp ), dest_backup -> start_time );
532
- elog (LOG , "Restoring database from backup at %s" , timestamp );
532
+ elog (INFO , "Restoring the database from backup at %s" , timestamp );
533
533
534
534
join_path_components (control_file , dest_backup -> root_dir , DATABASE_FILE_LIST );
535
535
dest_files = dir_read_file_list (NULL , NULL , control_file , FIO_BACKUP_HOST );
536
536
537
- // TODO lock entire chain
538
- // for (i = parray_num(parent_chain) - 1; i >= 0; i--)
539
- // {
540
- // pgBackup *backup = (pgBackup *) parray_get(parent_chain, i);
541
- //
542
- // /*
543
- // * Backup was locked during validation if no-validate wasn't
544
- // * specified.
545
- // */
546
- // if (params->no_validate && !lock_backup(backup))
547
- // elog(ERROR, "Cannot lock backup directory");
548
- //
549
- // restore_backup(backup, dest_external_dirs, dest_files, dbOid_exclude_list, params);
550
- // }
537
+ /* Lock backup chain and make sanity checks */
551
538
for (i = parray_num (parent_chain ) - 1 ; i >= 0 ; i -- )
552
539
{
553
540
pgBackup * backup = (pgBackup * ) parray_get (parent_chain , i );
554
541
542
+ if (!lock_backup (backup ))
543
+ elog (ERROR , "Cannot lock backup %s" , base36enc (backup -> start_time ));
544
+
555
545
if (backup -> status != BACKUP_STATUS_OK &&
556
546
backup -> status != BACKUP_STATUS_DONE )
557
547
{
@@ -638,6 +628,10 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
638
628
pg_atomic_clear_flag (& file -> lock );
639
629
}
640
630
631
+ /*
632
+ * Close ssh connection belonging to the main thread
633
+ * to avoid the possibility of been killed for idleness
634
+ */
641
635
fio_disconnect ();
642
636
643
637
threads = (pthread_t * ) palloc (sizeof (pthread_t ) * num_threads );
@@ -735,8 +729,13 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
735
729
if (external_dirs != NULL )
736
730
free_dir_list (external_dirs );
737
731
738
- parray_walk (dest_files , pgFileFree );
739
- parray_free (dest_files );
732
+ for (i = parray_num (parent_chain ) - 1 ; i >= 0 ; i -- )
733
+ {
734
+ pgBackup * backup = (pgBackup * ) parray_get (parent_chain , i );
735
+
736
+ parray_walk (backup -> files , pgFileFree );
737
+ parray_free (backup -> files );
738
+ }
740
739
}
741
740
742
741
/*
0 commit comments