LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to copy all files? (https://www.linuxquestions.org/questions/linux-general-1/how-to-copy-all-files-505128/)

MarkGaleck 11-26-2006 11:02 PM

how to copy all files?
 
I want to copy the whole Linux filesystem tree (including hidden system files and links) into a new directory, say /a.

The distribution I have is a freshly installed RH ES version 4. I tried both command-line cp with various options, and GUI, as root (and taking care not to recursively copy /a into itself). Some files get copied but I get permissions problems, "internal failures" and eventually hangs.

So, what is the best way to do this?

(the reason why I want to do this seemingly weird task, is that the sub-filesystem will be remotely NFS mounted to run on another machine)

Thank you for any insight. Mark Galeck

nadroj 11-26-2006 11:21 PM

try and cp all files in the main folders individually, ie, /bin, /boot, /etc, and so on. when you get to a problem folder then cd into it and try to narrow the folders down to the one that eventually gives you the error, by using wildcards (ie cp all folders that start with just a-n, then if successful m-z, etc.

ygloo 11-26-2006 11:38 PM

i backup with tar,
first stop any running processes and then

check mount points with "mount":

tar -cvpf dev_hda1.tar (--exclude=dir ) /
( if /dev/hda1 is mounted on "/")

this will archive all devices moounted on "/"

and if "/home" is on partition /dev/hda5
tar -cvpf dev_hda5.tar (--exclude=dir ) /home

extract with "tar -xvpf"
"-p" option is for preserving permissions

/bin/bash 11-27-2006 07:40 PM

I use rsync it handles all file types, and even the dev directory with no problem.
Suppose I have a partition mounted at /backup, this is what I would do to backup my entire filesystem:

for i in usr dev bin sbin lib home boot etc opt var; do rsync -a /$i/ /backup/$i/;done

It's that simple.

WARNING: I didn't test this one-liner.


All times are GMT -5. The time now is 03:17 PM.