¡Esta es una revisión vieja del documento!
Tabla de Contenidos
Cómo copiar archivos \ directorios \ sistemas de archivos a través de la red.
El artículo describe formas de copiar contenido a través de la red.
Al actualizar un servidor doméstico, copio todos los datos del servidor antiguo a un nuevo sistema. En los ejemplos a continuación, trabajo desde el nuevo servidor y ambos servidores están en la misma subred:
- Nuevo servidor (IP: 192.168.0.14)
- Servidor antiguo (IP: 192.168.0.1)
Los comandos ssh
y scp
se comunican a través de una conexión segura (puerto TCP 22). Tenga en cuenta que debe habilitar el demonio sshd
en el host remoto.
Copy Files / Directories
If you need to copy single files or directories, you can use the scp
command:
scp -r -v -p root@192.168.0.1:/etc /local_dir
Flag explanation:
- -r: recursive (copy all the content of
/etc
including its subdirectories) - -p: preserve file attributes (eg. file creation or modification times)
- -v: verbose output
In the example above we copy the /etc
directory located on a remote host (the old server: 192.168.0.1) to /local_dir
on the local host (“new” server).
Please note that the scp
command cannot copy the whole file system hierarchy including /proc
, /dev
or /lost+found
. Fortunately, there is a workaround which was provided by Patrick Volkerding.
Copy whole filesystem hierarchy
The following command should successfully copy a whole filesystem hierarchy:
ssh root@192.168.0.1 "(cd / ; tar cf - . )" | (mkdir -p /local_dir ; cd /local_dir ; umask 000 ; tar xvf -)