#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    Germany
    Posts
    230
    Rep Power
    16

    Creating multivolume tar files with incrementing name?


    Hi all,

    I've got a large directory and I want to tar it creating multi volume archives with incrementing numbers.

    However my tar file is constantly overwritten. I am doing something wrong, but I don't know where to add the incrementing number. or howto...

    this is my tar line:

    Code:
    tar -cf test_backup.tar -M -L 912000 /dir_to_tar/ -R -p
    So how should it look like?
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    867
    Rep Power
    391

    Cool



    Unless you want something more complex, the best would be to add the date to the file name:
    Code:
    tar -cf test_backup_`date +%Y%m%d`.tar /dir_to_tar/
    PS: I removed bogus options.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    Germany
    Posts
    230
    Rep Power
    16
    Originally Posted by LKBrwn_DBA

    Unless you want something more complex, the best would be to add the date to the file name:
    Code:
    tar -cf test_backup_`date +%Y%m%d`.tar /dir_to_tar/
    PS: I removed bogus options.
    Thanks for the reply. The problem is: The dir I want to archive has about 3 gigs of content. The system is configured to allow files no larger than 1 gig. So I want to archive the whole directoy creating multi volume files from it.

    Therefore I used -L 912000. But I need to add some kind of incrementing number else the archive will be overwritten again and again.
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    867
    Rep Power
    391

    Cool



    OK, then use the 'split' command:

    Code:
    tar -cf - /dir_to_tar/|split -b 2000m - test_backup_`date +%Y%m%d`.tar.
    #--Or just:
    tar -cf - /dir_to_tar/|split -b 2000m - test_backup.tar.


  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    Germany
    Posts
    230
    Rep Power
    16
    Originally Posted by LKBrwn_DBA

    OK, then use the 'split' command:

    Code:
    tar -cf - /dir_to_tar/|split -b 2000m - test_backup_`date +%Y%m%d`.tar.
    #--Or just:
    tar -cf - /dir_to_tar/|split -b 2000m - test_backup.tar.



    hmmm me dumb...

    still ain't working...

    there is no option called split and there is no option with b...

    I only got the -M option for multi archive and the manual says:

    -M
    --multi-volume Create/list/extract multi-volume archive.
    -n
    --norecurse Don't recurse into subdirectories when creating.
    --volno-file file File name with volume number to start with.


    But I don't get it to work...
  10. #6
  11. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    867
    Rep Power
    391

    Cool




    split and -b are NOT options for tar, split is a separate command and -b is an option for split.

    In the example I posted there is a "pipe" (|) between the tar and the split commands.


  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    Germany
    Posts
    230
    Rep Power
    16
    Originally Posted by LKBrwn_DBA


    split and -b are NOT options for tar, split is a separate command and -b is an option for split.

    In the example I posted there is a "pipe" (|) between the tar and the split commands.


    like I said... I am dumb.

    anyways... the problem I have is: (which I have already noted)
    The dir I want to archive has about 3 gigs of content. The system is configured to allow files no larger than 1 gig.

    Since the archive gets larger than the 1 GB it simply won't work with split...

    well, I'll have to call the support to remove this ridiculous file limit... otherwise it won't probably work...

    Thanks anyway for your help!
  14. #8
  15. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    867
    Rep Power
    391

    Cool



    The "-b 2000m" option in split will create files not larger than 2000 Megabytes ( < 2 GIG)

    Did you try this command?:
    Code:
    tar -cf - /dir_to_tar/ | split -b 2000m - test_backup.tar.
    PS: To create files not larger than 1 Gig use -b 1000m option.


    Last edited by LKBrwn_DBA; March 7th, 2007 at 11:27 AM.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    Germany
    Posts
    230
    Rep Power
    16
    Originally Posted by LKBrwn_DBA

    The "-b 2000m" option in split will create files not larger than 2000 Megabytes ( < 2 GIG)

    Did you try this command?:
    Code:
    tar -cf - /dir_to_tar/ | split -b 2000m - test_backup.tar.
    PS: To create files not larger than 1 Gig use -b 1000m option.



    It worked!!!! thanks a lot! maybe i just misspelled something or so! Works like a charm now! Thanks again!
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    Germany
    Posts
    230
    Rep Power
    16
    just for the dumb me... how do I extract those multi volume archives?

    I tried: tar -xfm volume.tar.aa

    But well... it didn't work again... :/

IMN logo majestic logo threadwatch logo seochat tools logo