Results 1 to 2 of 2

Thread: Archive Script

  1. #1
    Join Date
    Sep 2006
    Beans
    399

    Archive Script

    I'm looking for a script that can take a series of folders that use a date label format, compress each in a gunzip and remove the existing folder.

    ie


    20120915
    20120917
    20121011
    ..

    create
    20120915.tar.gz

  2. #2
    Join Date
    Dec 2007
    Beans
    416

    Re: Archive Script

    Verify that the archives are created correctly before adding the rm line. Try this:
    Code:
    #!/bin/bash
    
    FOLDERS=$(ls /path/to/folders)
    
    for i in $FOLDERS
         do
              tar -czf /path/to/archive/$i.tar.gz $i
         done
    
    rm -rf /path/to/folders/$i
    
    exit 0
    Last edited by newbie-user; August 2nd, 2013 at 07:19 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •