LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   copy whole filesystem via scp ? (http://www.linuxquestions.org/questions/slackware-14/copy-whole-filesystem-via-scp-4175449321/)

WiseDraco 02-09-2013 02:08 PM

copy whole filesystem via scp ?
 
Hello!
Today i try to copy a whole filesystem from old server to directory of new with command like scp -r -s -v 192.168.1.1:/ /second/Old_server
but it stops after another time with last lines like copy TtyS ?
i try to copy another ( data_ disk ) with that manner and too have a stop. i think, it try copy directory like a /lost+found and stuck there. it be can copy whole system on scp? if i remember xorrectly, cp -ax have do it, it has some similar for scp? search over google, not see a solution...

volkerdi 02-09-2013 02:19 PM

The problem is that scp won't handle special files like devices. But something like this will do the trick:

ssh root@192.168.1.1 "(cd / ; tar cf - . )" | (mkdir -p /second/Old_server ; cd /second/Old_server ; tar xvf -)

WiseDraco 02-09-2013 02:21 PM

thanks,ill try it tommorow :)
P.S. and thanks for the slackware - i use it from 4.0, mainly for routers \ servers, but also a 3-4 years also as only desktop system too :) some time i use mandriva / mandrake for desktop, but it's "microsoft way" with glucks, and strange things bored me :)

volkerdi 02-09-2013 05:37 PM

A quick addendum -- you might have to set umask 000 on the receiving end to avoid filtering perms on /tmp and certain files that might be writable by a group. Here's a fixed command line:

ssh root@192.168.1.1 "(cd / ; tar cf - . )" | (mkdir -p /second/Old_server ; cd /second/Old_server ; umask 000 ; tar xvf -)

WiseDraco 02-10-2013 03:25 AM

Thank you very much! looks like working - in that moment files copying, and some hours continued this state * ~250 Gb :) )
with your permission, i want to put that command somewhere in slackware docs ( docs.slackware.com), for others, and even me can find this command when it need next time ;)

volkerdi 02-10-2013 03:56 AM

Quote:

Originally Posted by WiseDraco (Post 4888088)
Thank you very much! looks like working - in that moment files copying, and some hours continued this state * ~250 Gb :) )
with your permission, i want to put that command somewhere in slackware docs ( docs.slackware.com), for others, and even me can find this command when it need next time ;)

Absolutely. Be my guest.

kikinovak 02-10-2013 05:03 AM

Quote:

Originally Posted by WiseDraco (Post 4887789)
Hello!
Today i try to copy a whole filesystem from old server to directory of new with command like scp -r -s -v 192.168.1.1:/ /second/Old_server
but it stops after another time with last lines like copy TtyS ?
i try to copy another ( data_ disk ) with that manner and too have a stop. i think, it try copy directory like a /lost+found and stuck there. it be can copy whole system on scp? if i remember xorrectly, cp -ax have do it, it has some similar for scp? search over google, not see a solution...

I'm not sure if this is exactly what you need, but you might want to have a look at this:

http://sourceforge.net/projects/g4l/

I'm using it in conjunction with a local FTP server. Works great.

WiseDraco 02-10-2013 05:15 AM

Quote:

Originally Posted by kikinovak (Post 4888175)
I'm not sure if this is exactly what you need, but you might want to have a look at this:

http://sourceforge.net/projects/g4l/

I'm using it in conjunction with a local FTP server. Works great.

looks, it is not i want in this case. for backup i some years ago in few places used a backuppc solution - very good, imho.

WiseDraco 05-10-2016 08:12 AM

Hello again!

the script:


ssh root@192.168.1.1 "(cd / ; tar cf - . )" | (mkdir -p /second/Old_server ; cd /second/Old_server ; umask 000 ; tar xvf -)

was great, but today i try to copy whole filesystem from one redhat system to external hdd, and all output stops on that
moment:

tar: ./sys/module/battery/sections/.init.text: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/battery/sections/.text: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/battery/refcnt: File shrank by 4094 bytes; padding with zeros
tar: ./sys/module/ac/sections/.strtab: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.symtab: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.module_sig: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.bss: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.gnu.linkonce.this_module: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.data: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/__versions: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.rodata.str1.1: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.exit.text: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.init.text: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/sections/.text: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/ac/refcnt: File shrank by 4094 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.strtab: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.symtab: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.module_sig: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.bss: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.gnu.linkonce.this_module: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.data: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/__versions: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.altinstructions: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.rodata.str1.1: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/__param: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.rodata: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.exit.text: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.init.text: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.altinstr_replacement: File shrank by 4085 bytes; padding with zeros
tar: ./sys/module/uhci_hcd/sections/.text: File shrank by 4085 bytes; padding with zeros



as we see, it try to copy /sys directory too.

there can be put exclusions for some directory, for it not get copied?

Z038 05-10-2016 08:24 AM

Look at the --exclude and --exclude-from options of tar.

kjhambrick 05-10-2016 10:33 AM

WiseDraco --

The commands I sent look too dangerous.

I've deleted the content of my post.

I am pretty sure rsync can do what you need. I don't understand your system setup well enough to send a safe command.

-- kjh

WiseDraco 05-11-2016 06:18 AM

Code:

ssh root@11.11.11.11 "(cd / ; tar cf - --exclude=sys --exclude=proc --exclude=dev --exclude=tmp --exclude=run . )" | (cd /mnt/hd/URIGA ; umask 000 ; tar xvf -)
looks like that construction works good.

jpollard 05-16-2016 08:11 AM

I suggest specifying "--one-file-system" to the "tar cf - ." to prevent it from trying to copy the /dev filesystem (as well as /proc, /tmp if it is a tmpfs, and stick to the goal of "copy a whole filesystem".

Much better than trying to use the exclude options.

orbea 05-16-2016 10:49 AM

Just use rsync.

https://wiki.archlinux.org/index.php...kup_with_rsync

perbh 05-16-2016 07:32 PM

I think there may well be a problem (or two) if you copy a 'live' filesystem with just about any method ...
Several years ago I did a live copy - only to find that the /proc filesystem occupied about 1GB while it is empty for a non-live filesystem. Those were in the days when 1GB was a _lot_ of diskspace. Ever after that - I boot from a usb-stick (or live cd/dvd) and copy the now non-live fs to another medium/partition - ne'er had a problem!
What I used was Alan Cox (anyone remember him?) backup-script which was almost the double of PV's above - ie
Code:

(cd $FROM && tar cf - .) | (cd $TO && tar xvpf -)
Note the 'p'-option - kinda important!!


All times are GMT -5. The time now is 08:54 PM.