Backup Files and Partitions with dd and netcat
This paper walks through various scenarios where dd and netcat can be used to backup files for administrative and forensic purposes. This paper is expected to grow over time and will be updated as time permits.
The first example uses OpenBSD 3.9 with nc that comes with base as the server host, and NetBSD 3.99.14 with netcat-1.10nb2 from pkgsrc as the client.
We will setup OpenBSD to listen on port 9999, and redirect output to “backup.file”
server# nc -l -p 9999 > backup.file
Once nc has received the file, it will automatically terminate the process.
Now, let’s backup a file. (Assume 10.0.0.2 is the IP address of the OpenBSD server).
client# cat file-to-backup | nc 10.0.0.2 9999
It’s as simple as that. And you can just verify the md5 checksum to be sure.
client# md5 file-to-backup MD5 (file-to-backup) = 8320752ece7caf11f7212d790b48cb92 server# md5 backup.file MD5 (backup.file) = 8320752ece7caf11f7212d790b48cb92
UPDATE: If you’re interested in encrypting these transfers, please refer to our article here
Posted: January 17th, 2007 under DragonFlyBSD, FreeBSD, NetBSD, Networking, OpenBSD, Papers, System Administration.
Comments: 1
Comments
Comment from Denis
Time: February 25, 2007, 2:41 pm
Nice tip, thank you :)
I just discovered your site and it is a very good work !

Write a comment