command line - How can I reliably count the number of increments in an rdiff-backup directory? - Ask Ubuntu


the rdiff-backup utility used create incremental mirror of directory tree. i'd find out number of increments saved, , save number variable value. i'm doing within bash script, , need still have access return code of rdiff-backup command when completes.

the command can run output statistics:

rdiff-backup --print-statistics $source_dir $mirror_dir 

which gives:

--------------[ session statistics ]-------------- starttime 1478018786.00 (tue nov  1 16:46:26 2016) endtime 1478018802.13 (tue nov  1 16:46:42 2016) elapsedtime 16.13 (16.13 seconds) sourcefiles 41812 sourcefilesize 16462964041 (15.3 gb) mirrorfiles 41812 mirrorfilesize 16462964041 (15.3 gb) newfiles 1 newfilesize 0 (0 bytes) deletedfiles 1 deletedfilesize 0 (0 bytes) changedfiles 2 changedsourcesize 0 (0 bytes) changedmirrorsize 0 (0 bytes) incrementfiles 4 incrementfilesize 64 (64 bytes) totaldestinationsizechange 64 (64 bytes) errors 0 -------------------------------------------------- 

the same information can found in time stamped statistics file within special rdiff-backup-data directory within mirror directory, following filename example:

/mirror_dir/rdiff-backup-data/session_statistics.2016-11-01t16:46:26z.data 

alternatively increments can listed in different format using separate command:

rdiff-backup --list-increments mirror_dir 

which outputs:

found 43 increments:     increments.2016-10-27t20:57:01+01:00.dir   thu oct 27 20:57:01 2016     increments.2016-10-27t23:57:01+01:00.dir   thu oct 27 23:57:01 2016     increments.2016-10-28t02:57:01+01:00.dir   fri oct 28 02:57:01 2016     increments.2016-10-28t05:57:01+01:00.dir   fri oct 28 05:57:01 2016     increments.2016-10-28t08:57:01+01:00.dir   fri oct 28 08:57:01 2016     increments.2016-10-28t11:57:01+01:00.dir   fri oct 28 11:57:01 2016 ...     increments.2016-11-01t16:00:14z.dir   tue nov  1 16:00:14 2016 current mirror: tue nov  1 16:46:26 2016 

i can't figure out whether should finding latest session statistics file , grepping value of incrementfiles field, or divert output of original command --print-statistics option, or whether separately filtering out number first line of --list-increments version more sensible.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User