Find the answer to your Linux question:
Results 1 to 5 of 5
Hi Guys, I have a problem that i'm stuck with. I want to create a backup tar file of the files that have changed in the last 24hours. This is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2006
    Posts
    2

    Creating a tarball from a txt file


    Hi Guys,

    I have a problem that i'm stuck with. I want to create a backup tar file of the files that have changed in the last 24hours. This is the find command i have that works perfectly.

    Code:
    find ./ -mtime -1 -print > changes.txt
    I want to then create a tar of all the files shown in changes.txt but i cant get the right command to do this.

    This is the command i have at present.

    Code:
    tar -cvvf file.tar | cat changes.txt
    This results in the tar command saying no file and then the changes.txt file listing its contents.

    I have also tried

    Code:
    tar -cvvf file.tar < cat changes.txt
    which advises that cat is not found

    Code:
    tar -cvvf file.tar << cat changes.txt
    does not work either
    Does anyone have any idea how i can do this?
    I have even tried this code to no avail.

    Code:
    tar -cvvf file.tar < find ./ -mtime -1 -print
    Any help would be awesome

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    It's an awkward problem to use find with tar in this way. That doesn't necessarily mean it should not be attempted, but it's possible there is a better tool for the job.

    It sounds to me like what you really may be interested in is rsync. (My impression is that you're trying to do incremental backups.)

  3. #3
    Just Joined!
    Join Date
    Nov 2006
    Posts
    2
    I tried to man rsync and mirror but both are not available.

    I'm actually using a SCO Server - not Redhat - but the commands should be similar.

    Tar is not designed to take an input from a text file?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    You could do it like so:
    Code:
    tar cvf backup.tar $(cat text-file-here)
    That might get tricky depending on how you build the text file, and especially if any file names contain spaces. That'll require some thought.

    If you'd like to pursue rsync, maybe whatever you're running has a package available. (If not, you could always build it from source.)

  6. #5
    Linux User muha's Avatar
    Join Date
    Jan 2006
    Posts
    290
    Use find, xargs and tar in a one-liner.
    Code:
    find ./ -mtime -1 -type f -print| xargs tar -czf ../tartest.tar.gz
    -type f specifies only files
    Create one tar in the directory one level up called tartest.tar.gz
    Now what? You have Linux installed and running. The GUI is working fine, but you are getting tired of changing your desktop themes. You keep seeing this "terminal" thing. Don't worry, they'll show you what to do @
    <~ http://www.linuxcommand.org/ ~>

Posting Permissions

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