mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-23 11:45:36 +02:00
Add simple progress bar with option --progress.
This commit is contained in:
parent
02ac17bb6b
commit
6ce7163a8a
16
backup.c
16
backup.c
@ -38,7 +38,9 @@ static XLogRecPtr stop_backup_lsn = InvalidXLogRecPtr;
|
||||
const char *progname = "pg_arman";
|
||||
|
||||
/* list of files contained in backup */
|
||||
parray *backup_files_list;
|
||||
parray *backup_files_list;
|
||||
static volatile uint32 total_copy_files_increment;
|
||||
static uint32 total_files_num;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -309,6 +311,10 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
|
||||
if (!check)
|
||||
dir_create_dir(dirpath, DIR_PERMISSION);
|
||||
}
|
||||
else
|
||||
{
|
||||
total_files_num++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_threads < 1)
|
||||
@ -337,6 +343,8 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
|
||||
parray_get(backup_files_list, i));
|
||||
}
|
||||
|
||||
total_copy_files_increment = 0;
|
||||
|
||||
/* Run threads */
|
||||
for (i = 0; i < num_threads; i++)
|
||||
{
|
||||
@ -352,6 +360,9 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
|
||||
pg_free(backup_threads_args[i]);
|
||||
}
|
||||
|
||||
if (progress)
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
/* Notify end of backup */
|
||||
pg_stop_backup(¤t);
|
||||
|
||||
@ -1014,6 +1025,9 @@ backup_files(void *arg)
|
||||
}
|
||||
else
|
||||
elog(LOG, "unexpected file type %d", buf.st_mode);
|
||||
if (progress)
|
||||
fprintf(stderr, "\rProgress %i/%u", total_copy_files_increment, total_files_num-1);
|
||||
__sync_fetch_and_add(&total_copy_files_increment, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ Common Options:
|
||||
-c, --check show what would have been done
|
||||
-j, --threads=NUM num threads for backup and restore
|
||||
--stream use stream for save/restore WAL during backup
|
||||
--progress show progress copy files
|
||||
|
||||
Backup options:
|
||||
-b, --backup-mode=MODE full,page,ptrack
|
||||
|
@ -39,6 +39,7 @@ bool stream_wal = false;
|
||||
bool disable_ptrack_clear = false;
|
||||
static bool backup_logs = false;
|
||||
static bool backup_validate = false;
|
||||
bool progress = false;
|
||||
|
||||
/* restore configuration */
|
||||
static char *target_time;
|
||||
@ -62,6 +63,7 @@ static pgut_option options[] =
|
||||
{ 'b', 'c', "check", &check },
|
||||
{ 'i', 'j', "threads", &num_threads },
|
||||
{ 'b', 8, "stream", &stream_wal },
|
||||
{ 'b', 11, "progress", &progress },
|
||||
/* backup options */
|
||||
{ 'b', 9, "disable-ptrack-clear", &disable_ptrack_clear },
|
||||
{ 'b', 10, "backup-pg-log", &backup_logs },
|
||||
@ -239,6 +241,7 @@ pgut_help(bool details)
|
||||
printf(_(" -c, --check show what would have been done\n"));
|
||||
printf(_(" -j, --threads=NUM num threads for backup and restore\n"));
|
||||
printf(_(" --stream use stream for save/restore WAL during backup\n"));
|
||||
printf(_(" --progress show progress copy files\n"));
|
||||
printf(_("\nBackup options:\n"));
|
||||
printf(_(" -b, --backup-mode=MODE full,page,ptrack\n"));
|
||||
printf(_(" -C, --smooth-checkpoint do smooth checkpoint before backup\n"));
|
||||
|
@ -211,6 +211,7 @@ extern parray *backup_files_list;
|
||||
extern int num_threads;
|
||||
extern bool stream_wal;
|
||||
extern bool disable_ptrack_clear;
|
||||
extern bool progress;
|
||||
|
||||
/* in backup.c */
|
||||
extern int do_backup(pgBackupOption bkupopt);
|
||||
|
Loading…
x
Reference in New Issue
Block a user