LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   smbclient & dd (http://www.linuxquestions.org/questions/linux-server-73/smbclient-and-dd-932160/)

saman_artorious 03-01-2012 09:53 AM

smbclient & dd
 
you know I am told to get an image of the whole ubuntu system on my server shared folder.
If you have used dd before to get an image of the occupied space on the system please lemme know bout your command.
(I preferably want dd to only get an image of the occupied file system not the free space)

Well, here comes the next part. You know, though I can view my server shared folder graphically, I cannot do it using shell command. The server has the following path:
Code:

smb://username@safe/mysharedfolder
(username and mysharedfolder have the same name)

I tried different commands for smbclient to connect to the server but it failed. Any helps would be appreciable.

catkin 03-01-2012 11:20 AM

dd will copy everything, including free space but you can a) set the free space to all zeroes and b) compress the output. Assuming the file system you want to copy is / and it is on /dev/sda1, as root:
Code:

dd if=/dev/zero of=/trash
rm /trash
dd if=/dev/sda1 conv=sync,noerror | gzip > /path/to/file/not/on/root/filesystem/sda.gz

If the contents of the / file system are changing during the above you will not get a "snapshot in time" so it is better run after booting a standalone system such as Knoppix or a functional live CD/DVD, in which case change /trash as appropriate.

theNbomr 03-01-2012 12:04 PM

It isn't clear whether you want to use the SMB filesystem as the source or as the destination of the dd image. dd works on files and devices, but not on network shares, which are neither. If you want to make a backup of a network share, you are much better off to use either a backup utility (maybe even dd) on the file server host.
If you want to make an image of a partition on a local filesystem, and store the image as a file on a network share, then I suggest mounting the SMB share on your local filesystem before starting to create the dd image, and use the mounted network filesystem as the storage for the dd image.

Making a dd image of a mounted partition is a recipe for BAD THINGS. A file oriented backup using rsync is probably a better idea, and will be more efficient in terms of net data transfer, and size of the resulting copy, although the result will not be a single image file. You can still create a single file version of the backup, if that is what you require for archival or transport purposes.

--- rod.

saman_artorious 03-02-2012 07:34 AM

Quote:

Originally Posted by catkin (Post 4616065)
dd will copy everything, including free space but you can a) set the free space to all zeroes and b) compress the output. Assuming the file system you want to copy is / and it is on /dev/sda1, as root:
Code:

dd if=/dev/zero of=/trash
rm /trash
dd if=/dev/sda1 conv=sync,noerror | gzip > /path/to/file/not/on/root/filesystem/sda.gz

If the contents of the / file system are changing during the above you will not get a "snapshot in time" so it is better run after booting a standalone system such as Knoppix or a functional live CD/DVD, in which case change /trash as appropriate.

I didn't get the last part! in the code you gather all free space in /trash, and then remove trash. So, there only remains occupied space. I don't understand the next step related to live CD/DVD, what that's gonna do with this at all? could you explain it in more detail plz.

and, let's be more accurate here, I need frist to mount my server shared folder using this
mount -t cifs //safe/mysharedfolder -o username=user,password="password" /mnt/share
and then get a backup of whole system n place it on server. this I shall only change the path to file not on root filesystem to /mnt/shared right?
Code:

dd if=/dev/zero of=/trash
rm /trash
dd if=/dev/sda1 conv=sync,noerror | gzip > /path/to/file/not/on/root/filesystem/sda.gz


catkin 03-02-2012 07:40 AM

Same as what theNbomr wrote -- using dd to copy a mounted file system is not good so, if it is the / file sytem you want to back up you can't umount it while it is being used to run GNU/Linux. The solution is to boot GNU/Linux from a CD or DVD.

theNbomr 03-02-2012 12:13 PM

Quote:

Originally Posted by saman_artorious (Post 4616759)
Code:

dd if=/dev/zero of=/trash
rm /trash
dd if=/dev/sda1 conv=sync,noerror | gzip > /path/to/file/not/on/root/filesystem/sda.gz


This is very likely to be the root filesystem. Creating an image of the mounted root filesystem will definitely not be a good idea, if you intend to restore it as a working root filesystem image in the future.
--- rod.

saman_artorious 03-02-2012 02:54 PM

Quote:

Originally Posted by catkin (Post 4616761)
Same as what theNbomr wrote -- using dd to copy a mounted file system is not good so, if it is the / file sytem you want to back up you can't umount it while it is being used to run GNU/Linux. The solution is to boot GNU/Linux from a CD or DVD.

should it be a live cd/dvd? or i can also use the same distribution dvd? and if any, shall simply log in in live mode and then take a backup of the / file system? but would the / file system, when i login from a live cd or dvd? bcoz m not mounting my system anymore whereas the / filesystem of the live cd or dvd is mounted instead!

theNbomr 03-02-2012 03:03 PM

Any CD/DVD that does not mount the partition which you are trying back-up would be suitable. That probably includes most live CDs/DVDs, including most installation CDs. If you can get to a shell, you should be able determine what is mounted by either running mount with no arguments, or inspecting /etc/mtab. Even if the target partition is mounted, you can very likely safely unmount (umount) it for the purpose of making a backup.
--- rod.


All times are GMT -5. The time now is 02:57 AM.