Using filesync for Disaster Recovery, Business Continuance, and Mobility
Since the September 11th disaster, many information technology professionals are looking for disaster recovery and business continuance solutions. Disaster recovery and business continuance are intended to ensure that a business can survive a disaster, recover from it, and continue to handle normal business activities. Implementation of a disaster recovery and business continuance plan can include offsite data storage, disaster recovery procedures, security implementations, and hot, disaster recovery sites.
The Solaris™ Operating Environment (Solaris OE) filesync(1) command can be used to help with both disaster recovery and business continuance. The filesync(1) command synchronizes ordinary, directory, or special files. It can be used to synchronize data between two servers that are in the same data center or miles apart. In the event of a primary server failure, the synchronized secondary data can be used to continue business activities. Additionally, mobile employees can synchronize data between a laptop and an office server in the event of laptop damage or loss.
UNIX™ users have been copying and synchronizing files and directories for a long time. For instance, the RSYNC command has been used for some time for one-way synchronization between two files or directories. The filesync(1) command does bidirectional synchronization. If files in the source directory change or if files change in the destination directory, the filesync(1) command synchronizes the files in both places. You can also use the -o option with the filesync(1) command to overwrite only the files that were modified, which might be quicker than restoring the whole directory.
With the filesync(1) command, you can do the following:
Recover from a disaster
You can recover files from a previously synchronized directory on a backup server to a production directory on a production server. You can also use filesync(1) to recover files that were synchronized to a production server if the files on that server are lost or corrupted. Finally, if your laptop computer is lost, stolen, or damaged, you can use filesync(1) to restore your files to a new laptop computer.
Continue business activities
You can work from your laptop or workstation at home if the office servers are down.
Create a point-in-time copy of your data
You can use the point-in-time copy of your data for testing or for returning your system to a known state.
You can synchronize your laptop so that you are prepared to give presentations, read your email, or maintain your web siteanywhere, anytime.
The filesync(1) command creates the .packingrules file and the .filesync-base file in the home directory of the user ID that evoked the command. The .packingrules file controls the functionality of the filesync(1) command, and the .filesync-base file lists every file that was synchronized, along with the file's checksum value.
If you edit the same file on both servers, the filesync(1) command will notify you that you need to fix this situation. Also, you can use the -f option to force a synchronization one way or the other. For example, the filesync -f src command will overwrite the files on the destination server with the files on the source server (src). If there is a conflict in which the same file was changed in both the source directory and the destination directory, the -f option will overwrite the incorrect file with the correct file. The following example, shows the output of a reconciliation operation:
user%: filesync RECONCILE /production and /databackup (1 files) -> 0 copies, 0 deletes, 0 ownership <- 0 copies, 0 deletes, 0 ownership UNRESOLVED CONFLICTS: 1 data.txt (two different versions)
In this example, both files were changed since the last synchronization, so you have to determine which file is the good file. For instance, if you determine that /production/data.txt is the good file, use the -f option with the filesync(1) command. Because the /production directory is the source directory, use the following command:
user%: filesync -f src cp /production/data.txt /databackup/data.txt RECONCILE /production and /databackup (1 files) -> 1 copies, 0 deletes, 0 ownership <- 0 copies, 0 deletes, 0 ownership
Synchronizing Two Directories
This section contains a procedure for synchronizing two directories. After you have synchronized the directories the first time, use the filesync(1) command without options to resynchronize the directories. You can use crontab(1M) to resynchronize the directories on a regular basis.
To Synchronize Two Directories
Choose the directory you want to synchronize.
In this example, we use the /data/oracle directory.
Choose the directory to which you want to synchronize.
In this example, we use the /backupdisk/oracle directory. The first time you use the filesync(1) command, the /backupdisk/oracle directory must be empty. Otherwise, the filesync(1) command will return errors, indicating that it cannot resolve conflicts, for every file in both directories.
Execute the following command:
user%: filesync -s /data -d /backupdisk oracle
When you want to resynchronize your files, issue the filesync(1) command without options. To synchronize your files automatically, use the cron(1M) command. For instance, to synchronize your files nightly at 1:00 a.m., add the following line to the crontab(1) file:
0 1 * * * /usr/bin/filesync