Tag Archives: windows

Compress Contents to Save Disk Space

Copy and Backup Utility Review – Robocopy or Xcopy, Which One?

Robocopy or Xcopy Which One to Use?

These two command line file copy utilities seem to provide the same functions. However don’t be deceived by the number of options xcopy provides. It is just a as it is a poor relative of the more robust, featured,
When to Use Xcopy and When to use Robocopy?
If you need advanced features such as backing-up, type of copy and you want 100% reliability of the copy process then Robocopy (robust copy) is your choice. If on the other hand, you don’t have a complex copy job Xcopy will do it. Xcopy is part of the operating system, it comes with Windows, whereas robocopy needs to be copied from another system, or you need to install the Resource Kit. To put it more simple, xcopy is always available as the shell command “copy”.

Features of Xcopy and Robocopy

Why not use the shell command copy then, is the next question. Because “copy” is just too minimal and cannot accomplish what the other two can. It only copies files and not directories with the afferent directory structure. It cannot copy attributes and ACLs.
In contrast, the other two file copy utilities are featured in such way that they can be easily used as backup systems if the correct options are setup. In conjunction with the scheduler and using a batch script this can be a powerful backup solution that is both inexpensive and flexible.
The features of Xcopy and Robocopy are: selective attributes replication, ACLs can be maintained or not for the files copied, ownership can be copied or not, folder structure replication, fully automation, archive attribute support – which makes it a real backup utility, file exclusion option, verification of the copied files, performance tuning.

What are the differences between Xcopy and Robocopy?

If we were to sum up we could say that Robocopy is way more powerful than Xcopy. But of course you might ask me for arguments to support my statement, here they are:
The most annoying thing about Xcopy is that you can’t use the network restartable mode if you copy ACls. Isn’t this annoying? For me this was enough of a reason to install the Resource Kit and get the Robocopy immediately. But wait, the list doesn’t stop here.

Robocopy as a Backup Software

Why is Robocopy worth writing about? Robocopy is a great software that can be used as a backup utility. Its features makes it fit for maintaining automated file backup using various approaches. It can be used for directory mirroring, for archiving files, for moving files, etc…
It can be used to copy only new or changed files, it can use the archive bit, as any good backup software would.
If the target directory is enabled for compression, it can save space as well.
Another application of Robocopy is during migrations or server upgrades. Because sometimes migrations or server changes are time sensitive, we need to copy as much as possible before switching to the new server. This where Robocopy comes in handy. You start the mirroring ahead of time, so all the files are copied. When the time of switching is close there are only minor changes to be done so the operation is very fast. The key options for this applications are: robocopy /MIR to mirror the directory, robocopy /MON:n to MONitor the source and run again when more than n changes occur and robocopy /MOT:m to MOnitor source and run again in m minutes Time, if changed.
Another neat application is to archive files that haven’t been used in a given period.
This command moves files that haven’t been used in 500 days, in restartable mode, copying the attributes, the file’s owner, and the ACL, excluding older files.
robocopy C:\FILES \\SERVER\FILES-ARCHIVE /e /zb /r:0 /w:1 /copy:daso /xo /move /MINLAD:500

Other Cheap Backup Utilities

Another cheap, (free), utility is xxcopy.
The utility competes with Robocopy, has versions for both 32 bit and 64 bit OS, and has more command switches.
However, this isn’t a free program for businesses, it is free for for personal use though.

Downloads and Resources

Download the resource kit for Windows 2003 here, (the resource kit contains robocopy): http://www.microsoft.com/download/en/details.aspx?id=17657
You can download xxcopy here: http://www.xxcopy.com/xcpydnld.htm
A robocopy GUI interface can be downloaded here: http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/UtilitySpotlight2006_11.exe
Another robocopy GUI interface can be downloaded here: http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/HoffmanUtilitySpotlight2009_04.exe

Compress files in Windows

As a Windows Network Administrator I always have to make space delete unneeded files, archive old files, compress files that we don’t need but we might need at some point.
I don’t use the same compression method every time, because the scenario is different. Here are a three compression methods for Windows.

Compress Files Using the NTFS Compression

Compress Contents to Save Disk Space

This method of compression only works on NTFS partitions. You don’t have the option for a FAT or FAT32 partition.
The most usual and easier way to do this is to use the Windows’ Graphical Interface and access the Advanced File Properties and select Compress contents to save disk space.

Compact – Compress files or folders from command line

If you would like to compress files from a batch file use this command line variant. Usually if you access the advanced file properties, (right-click => properties and => advanced) you have the option to compress contents to save space. Another good use of the command line is that it gives you a better view of the progress. The graphic interface sometimes hangs and you don’t know if the job is still active.

The command to compress a folder from within the folder is compact /c /s. It compresses all of the files within the folder and marks the folder as compressed so that new files are created compressed.

Why would you choose Compact and not Zipped Folder?

The main reason is that a compacted folder can be used by applications. In other words if the path of a log file points to a compacted folder this is transparent for the application that writes the log file. As a result your log files will be compacted. You cannot do this with Zipped folders or files.

Compress files using the Windows’ built-in zip archiving utility

Send to Compressed (Zipped) folder

Why would you choose Compressed (Zipped) Folder over the Compacted Folder?

The zipped Folder has better compression and better portability. The zipped folder has a slightly better compression rate, and you can copy the files to any other Operating System, send them by email and they will retain the compression. The compacted folders will only be compressed on the original location unless you compress the file again at the new destination. Note in the image below the difference between the two file compression formats. The Windows shell has the option to “show NTFS compressed files in color”, which is a great option. Note that the zipped file is slightly smaller than the compacted, (blue colored), one.

Compact (the native NTFS compression) vs Compress the send to Zipped Folder

Compact vs Compress click to enlarge

Is there a Compressed (zipped) Folder – command line variant?

Unfortunately, there isn’t any Windows built-in option. The good news though is that there is a free archiver that has a command line version as well. 7zip is a great free utility very flexible that manipulates all of the popular archiving file formats.

Compressing from the command line with 7zip is very simple, the simplest command is 7z a NewFolder.zip “New Folder” that compresses the folder New Folder into the archive: NewFolder.zip. For more options and switches type: 7z –h, note that 7z doesn’t understand the /? switch, usual on any Windows application.

Why would you choose 7Zip over the Windows’ built in compressing solutions?

The main reason is flexibility. 7zip has a lot of options/switches that control a lot of the compression aspects and it is very easy to use in a batch file.

An interesting application is to separately archive a lot of folders from a batch file. Let’s say you have 500 folders that you want to archive and you know you will be accessing those folders on a regular. It makes more sense to archive the folders separately and not in one big file. It is easier to access smaller zip files from the Windows shell and keeps the system responsive. To do this manually for 500 folders is a nightmare. Here is a command that runs from a batch file that will compress those folders separately, each folder one zip file:

for /D %%d in (*.*) do 7z a -tzip “%%d.zip” “.\%%d\*”

To run the command from the command line and not from a batch file the command is slightly different:

for /D %d in (*.*) do 7z a -tzip “%d.zip” “.\%d\*”

There are other great archiving utilities such as Winzip, Winrar, Pkzip, etc… They are not free, but you can get a trial-ware which in many cases is good enough for anybody.

A few tips on what to compress and what not.
Usually Installation files are already compressed so there is no benefit in compressing.
Digital photos in a jpg or gif format are already compressed using special algorithms.
PDF files don’t compress.
Text files, (plain text, log files, etc…) compress the best.
Word files can be compressed but not as much as the text files.