At my day job I deal with a fair amount of image data. We typically are shipping the data out on either hard drives, thumb drives, or via SFTP. On occasion we will some times burn it to a CD and/or a DVD. But until today all the data was either large sets (200-400GB) variety, or small, less than 1-2GB. However today’s shipment was 18GB. What to do? I didn’t have a spare USB thumb drive handy so I thought, ah I’ll just throw it on a couple of single layer DVDs. So my first order of business was to figure out how many. As it is with Linux/UNIX, there is pretty much already a tool for everything, if only you look hard enough 8-).
For this particular shipment all the image data was organized into a couple dozen folders, each weighing in a ~100-200MB. I quickly figured that 5 DVDs should be more than enough, but how to optimally fill each DVD? Luckily there’s a program called dirsplit which made this a breeze.
Again another tool I’ve never heard of, dirsplit is actually a Perl script that can analyze a directory and report the optimal way to burn it to a set of DVDs. Once it’s done analyzing a directory, it’ll report back a set of .list files, one per each DVDs worth of files. dirsplit is part of the package cdrkit which in addition to dirsplit, also includes the following programs:
- dirsplit: dirsplit utility
- genisoimage: Creates an image of an ISO9660 filesystem
- icedax: A utility for sampling/copying .wav files from digital audio CDs
- wodim: A command line CD/DVD recording program – (“write optical disk media”) – a cdrecord replacement
It can get a little confusing, but cdrkit, at least under Fedora & CentOS, is comprised of 4 individual RPMs, so we’re only going to be using dirsplit. I installed it like so:
dirsplit’s basic usage:
% dirsplit [options] [advanced options] < directory >
-H|--longhelp Show the long help message with more advanced options
-n|--no-act Only print the commands, no action (implies -v)
-s|--size NUMBER - Size of the medium (default: 4488M)
-e|--expmode NUMBER - directory exploration mode (recommended, see long help)
-m|--move Move files to target dirs (default: create mkisofs catalogs)
-p|--prefix STRING - first part of catalog/directory name (default: vol_)
-h|--help Show this option summary
-v|--verbose More verbosity
The complete help can be displayed with the --longhelp (-H) option.
The default mode is creating file catalogs useable with:
mkisofs -D -r --joliet-long -graft-points -path-list CATALOG
dirsplit -m -s 700M -e2 random_data_to_backup/
Once installed, cd <image data directory>, and run the following command:
…. Continue reading → [one-liner]: Using the Linux Command, dirsplit, to Dynamically Backup a Directory Over Multiple DVDs »»