Re: Dar slice numbering

Denis Corbin <[email protected]> Sat, 23 Dec 2006 20:45:59 +0100
Newsgroups gmane.comp.sysutils.backup.dar.general
Message-ID <[email protected]>
This question has just been answered in dar-support mailing-list. Here 
follows the answer that has been made to this question:

-----------------------------

Freddie Cash wrote:

 > First, excellent work on dar, it's become virtually indispensable in 
our server farm.  Especially when we want to move a physical server into 
a Xen virtual server (dar, LVM, Debian, and xen-tools are an awesome 
combination).


Thank you!

 >
 > However, one thing has always nagged at me about the way it numbers 
slices:
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:18 full-backup.1.dar
 > -rw-r--r--  1 root staff 159M Dec 21 13:41 full-backup.10.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:27 full-backup.2.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:38 full-backup.3.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:47 full-backup.4.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:56 full-backup.5.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 13:04 full-backup.6.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 13:13 full-backup.7.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 13:23 full-backup.8.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 13:38 full-backup.9.dar
 >
 > Can anyone see what bugs me?


No that's correct.

 >  And it gets even uglier when you have more than 20 or 30 slices. 
(Yes, I know I could just bump up the slice size, but that's not a 
solution ... merely a poor workaround.)


The problem is that dar cannot know before the archive is completed how
much slice it will require. Compression/encryption/place required for
DAR archive format/... make the thing impossible to foresee.

 >
 > Would it be possible to change the way dar numbers slices to use at 
the very least 2 digits.  So that the above would look like:
 >
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:18 full-backup.01.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:27 full-backup.02.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:38 full-backup.03.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:47 full-backup.04.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 12:56 full-backup.05.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 13:04 full-backup.06.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 13:13 full-backup.07.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 13:23 full-backup.08.dar
 > -rw-r--r--  1 root staff 1.0G Dec 21 13:38 full-backup.09.dar
 > -rw-r--r--  1 root staff 159M Dec 21 13:41 full-backup.10.dar
 >
 > Which is a lot nicer to look at.


but dar can generate archive with more than 99 slices... This would be
back ugly for that many slices... OK, let's have three digits, ... but
dar can generate archive with more than 999 slices ... This would be
back ugly for that many slices... we can continue on this way forever .

 >
 > Or, perhaps make the default 2-digit numbering, with a command-line 
option to override it (for those that know they'll need more than 99 
slices, or fewer than 10).
 >

Moreover, at reading time, dar would have to look for slice's name 1 or 
01 or 001 or 0001 or 00001 and so on, up to how much leading zero? 
Actually dar has no limit on the number of possible slices...

There is a way to address your restricted need to have slice named on 
two digits, it relies on a script to provide to dar thanks to its -E option.

This script renames the slice appending the leading zero you request, 
and adds a symlink on it, named by the original slice name. You can add 
to your .darrc file for you don't have to change the way you are using dar.


#cat addleading.tcsh
#!/bin/tcsh -f

if("$1" == "") then
    echo "usage: $0 <slice name>"
    exit
endif

set new_name = `echo "$1" | sed -rn -e 
's/^([^\.]+)\.([0-9])\.(.*)$/\1.0\2.\3/p'`

if("$new_name" != "") then
   mv "$1" "$new_name"
   ln -s "$new_name" "$1"
endif

#cat .darrc
create:
     -E "./addleading.tcsh '%p/%b.%n.%e'"
isolate:
     -E "./addleading.tcsh '%p/%b.%n.%e'"
merge:
     -E "./addleading.tcsh '%p/%b.%n.%e'"


Of course you will have to tune some parameters like the path to 
"addleading.tcsh" in your .darrc file, and you also decide to have the 
symlink stored in another directory than the one where are located the 
renamed slices.

Yet another solution if you want to have slices listed in order while 
you don't have them renamed at all is to sort them by creation date:

#ls -rtal
-rw-r--r-- 1 denis home 1048576 Dec 23 15:31 full-backup.1.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:33 full-backup.2.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:34 full-backup.3.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:36 full-backup.4.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:37 full-backup.5.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:39 full-backup.6.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:40 full-backup.7.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:43 full-backup.8.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:43 full-backup.9.dar
-rw-r--r-- 1 denis home 1048576 Dec 23 15:45 full-backup.10.dar
-rw-r--r-- 1 denis home   64208 Dec 23 15:47 full-backup.11.dar


Regards,
Denis.

-----------------------

T wrote:
> Hi,
> 
> This is my first post to the list. 
> I just hope that dar's slice numbering mechanism could be improved.
> Currently, it yields:
> 
> dar-archive.1.dar
> dar-archive.10.dar
> dar-archive.100.dar
> dar-archive.101.dar
> [...]
> dar-archive.109.dar
> dar-archive.11.dar
> dar-archive.110.dar
> [...]
> 
> Ie, the whole sequence is messed-up if I do a ls.
> 
> I hope that dar can equalize slice number width by padding leading zeroes,
> just like what rar or "seq --equal-width" do.  
> 
> thanks
> 
> $ dar -V
> 
>  dar version 2.3.0, Copyright (C) 2002-2052 Denis Corbin
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Dar-discussions mailing list
Dar-discussions-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/dar-discussions
signature.asc (application/pgp-signature, 252 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFjYeBpC5CI8gYGlIRAnAqAKCg49be9SQuD+JXDHboBGhcGelV1ACfX2by
bDNB04i7l8kBJqJnfUYJNEA=
=Xn9I
-----END PGP SIGNATURE-----