LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-16-2005, 12:02 AM   #1
tardigrade
Member
 
Registered: Jun 2004
Distribution: SuSE 9.1
Posts: 150

Rep: Reputation: 15
reclusive cp of ~/.hiddens


I want to backup all my program data in my home dir. that is all the .whatnots . I have tried these things (below) but none work right. Most copy all the regular folders like my music and video stuff which i do no want to backup.

ive tried these:
jeff@linux:~>cp -dp ./.* ~/etc/backups/jeff_data
cp: omitting directory `./.'
cp: omitting directory `./..'
cp: omitting directory `./.AbiSuite'
cp: omitting directory `./.acrobat'
cp: omitting directory `./.adobe'

jeff@linux:~> cp -dpR ./.* ~/etc/backups/jeff_data
only goes one deep

jeff@linux:~> cp -dpR ./. ~/etc/backups/jeff_data

i supose i could drag and drop but thats not fun and i cant make a script with that.
thanks!
 
Old 05-16-2005, 12:38 AM   #2
freakyg
Member
 
Registered: Apr 2005
Distribution: LFS 5.0 and 6.1
Posts: 705

Rep: Reputation: 30
Re: reclusive cp of ~/.hiddens

Quote:
Originally posted by tardigrade

jeff@linux:~> cp -dpR ./.* ~/etc/backups/jeff_data
only goes one deep

jeff@linux:~> cp -dpR ./. ~/etc/backups/jeff_data
have you tried::
Code:
 cp -Rav ~/.*
 
Old 05-16-2005, 01:33 AM   #3
tardigrade
Member
 
Registered: Jun 2004
Distribution: SuSE 9.1
Posts: 150

Original Poster
Rep: Reputation: 15
cp -Ra ~/.* ~/etc/backups/jeff_data
does the same thing. note that -dpR is the same a -a
thanks anyways.
 
Old 05-16-2005, 01:43 AM   #4
tardigrade
Member
 
Registered: Jun 2004
Distribution: SuSE 9.1
Posts: 150

Original Poster
Rep: Reputation: 15
'/home/jeff/./etc' -> `/home/jeff/etc/backups/jeff_data/./etc'

for some reason /. means something and it isnt working because of it. i think. this is stupid.
 
Old 05-16-2005, 02:47 AM   #5
fuzzyash
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: Fedora Core 4
Posts: 184

Rep: Reputation: 30
"." means "this directory", ".." means" the next directory up"

This is a good question, I'll look into it further.
 
Old 05-16-2005, 04:23 AM   #6
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
All right - you want to backup only the hidden files in a directory... try the following:

Code:
$ ls > nobackup.txt
$ tar zcvf backup.tgz .* -X nobackup.txt
the first line lists all the non-hidden files and directories in a text file
the second line creates a tarball containing everying in the current directory, including hidden files but excluding anything listed in the "nobackup.txt" file. That should only be hidden files.

Happy hunting.
 
Old 05-16-2005, 04:39 AM   #7
doc.nice
Member
 
Registered: Oct 2004
Location: Germany
Distribution: Debian
Posts: 274

Rep: Reputation: 34
maybe mirrordir is something for you,
but I don't know where to get it as rpm or tar.gz, in Debian there's an package available...
Mirrordir can make exact copies of a directory tree, also deleting files from the copy if they are deleted from the source. and there is an option to exclude certain files, in your case you would use a pattern that matches ~/[^.]*

btw. you should use this filemask in your experiments:
~/.??* in order to get all files starting with a dot and being at least 3 characters long, because recursive copying of .. is not a good idea
 
Old 05-16-2005, 07:25 AM   #8
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
I'm sure there are other ways to do this but here is one using find and cpio .
For example....
Code:
cd /home/fred
find . -depth -name '.*' | \
cpio --pass-through --preserve-modification-time \
--make-directories --verbose /mnt/backup
This copies the Desktop also, but you could experiment with --exclude if that bothers you.
 
Old 05-16-2005, 09:07 PM   #9
tardigrade
Member
 
Registered: Jun 2004
Distribution: SuSE 9.1
Posts: 150

Original Poster
Rep: Reputation: 15
so far so good. all of these seem to work or at least make sense if i didnt actually use them. THANKS EVERYONE!
 
Old 05-16-2005, 11:58 PM   #10
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
It's amazing how many different ways there are of doing something isn't it? BTW:
Code:
$ tar zcvf backup.tgz .??*
also seems to work. doc.nice had the best tip there, IMO.
 
Old 05-17-2005, 12:03 AM   #11
Boow
Member
 
Registered: Feb 2004
Distribution: Slackware 10.2
Posts: 669

Rep: Reputation: 32
how bout cp -a though tar cjvpf would work.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration