2
I recently had my second hard-drive of the past semester begin to fail on me and become unable to ghost to a new drive. I still had the first hd that failed so we ghosted that drive but now I need to get all the files and things that have changed since the date of the first ghosting (first failed hd -> second failed hd) onto the new drive (all files on second failed hd since a date -> third working hd). Is there an easy way to script this in the linux terminal or use another program?
I've looked into using the following commands but they haven't been successful and fail after the first few folders have been archived:
find . -type f -mtime -58 |xargs tar --no-recursion -czvf allmodified.tgz
tar czvf allmodified.tgz `find . -type f -mtime -58`
The find code works and locates all the files on the drive I need but I still can't find a way to get them to archive with file structure so that I can unpack the files on the new drive (third working hd) and they will be preserved where they were in the past 2 months.
I'm not the best at describing my problems so if you have confusion please ask questions and I'll do my best to answer them.
Any hints help, thank you so much!
Using this method would I then be able to 'unzip' the tar on my new drive and have it place files accordingly? – Samuel Kane – 2013-11-15T18:48:53.707
Yes. Just tested it on a set of sample files. Note that your tarball has to be extracted from the same root directory as it was tarred in. Also, tar will overwrite existing files. To prevent that, use
--skip-old-files
when extracting. – slhck – 2013-11-15T18:53:16.327So if I tarred it in the /media/ubuntu/OS directory of one, then I would need to move the tar to the /media/unbuntu/OS1 folder for the other drive? Could you also elaborate on how the --skip-old-files works when extracting (I'm really a novice at this), I'm not 100% confident I'm going to do this correctly and I'm going to ruin a lot of things. Thank you so much for your help – Samuel Kane – 2013-11-15T18:59:04.997
If you ran
find … | tar …
while you were in/media/ubuntu/OS/
, thencd /media/ubuntu/OS1/
andtar -xcvf allmodified.tar.gz --skip-old-files
, then only the missing files inOS1
are created from yourOS
backup. If you're unsure what will happen, try creating a smaller test archive first. Or list the contents of the archive withtar -tvf allmodified.tar.gz
and imagine that tar creates each of those with the path it spits out (e.g. iftar -tvf
writes./foo/bar
, then the file/media/ubuntu/OS1/foo/bar
will be created). In any case, I'd recommend a small test first. – slhck – 2013-11-15T19:13:28.933fantastic! thank you so much! I'll let you know the results once I've done the test and the whole project – Samuel Kane – 2013-11-15T19:21:21.973
No luck getting this to work on my disk, it just creates a .tar with nothing it in but doesn't update or display any further progress. I'm open to more suggestions! Thank you for the help so far! – Samuel Kane – 2013-11-15T20:15:58.233
Does
find . -type f -mtime -58
print the files you want? Can you try again with everything in the command on one line? It might not have worked if there's a newline in your command when you paste it. – slhck – 2013-11-15T20:38:38.017I ran this originally all on one line and the find... command does work to find all the files I want – Samuel Kane – 2013-11-15T21:03:00.900
Weird. You can come to chat if you want: http://chat.stackexchange.com/rooms/11524/discussion-between-slhck-and-samuel-kane – just ping me with @slhck and we'll figure this out.
– slhck – 2013-11-15T21:21:03.337