Go to content Go to navigation & search

welcome to weekeat.com

Navigation

navigation

feeds

choose: rss / atom


Content

Patching applications with rsync

posted 6 September 2006

Instead of extracting patch files in the actual live directory, or overwriting files into the live directory directly (via copying or moving), you can actually have the patches in the separate folder, and apply those patches using rsync locally.

The advantages of using rsync is that you can perform a dry run, meaning it performs a test transfer, without actually commiting it.

This way, you can actually check if the files getting replaced or copied across are correct. Once you’re satisfied, then you can perform the actual transfer of files.

If you’re unsure, here are the steps that you can follow:

Performing the dry run

For example, you have the live directory in /var/www/webapp/. You can extract the patches into, let’s say, /var/webpatch/. All you need to do then is, assuming you’re in /var directory, the following:

me@mycomp:~$ pwd /var me@mycomp:~$ rsync -rcvn webpatch/ www/webapp/ building file list … done file1.php file2.php sent 136 bytes received 38 bytes 348.00 bytes/sec total size is 64 speedup is 0.37

Notice the n option in the -rcvn above. This tells rsync to perform a dry run. It will report what will be replaced and what will be transferred so that you can evaluate them first.

Another important thing to notice is the folder paths all have trailing slashes (/). In rsync, the trailing slash means to transfer files under that folder and without the trailing slash means the transfer the folder AND the files. So, be careful.

Then perform the actual transfer

Once you’re happy that it is the right destination and the right files to be overwritten, you can perform the actual rsync by using the same command above, but without the n option like the following:

me@mycomp:~$ pwd /var me@mycomp:~$ rsync -rcv webpatch/ www/webapp/ building file list … done file1.php file2.php sent 136 bytes received 38 bytes 348.00 bytes/sec total size is 64 speedup is 0.37

That’s it. It’s is now transferred. Again, notice the -rcv option. It now does not contain the n option.

Double checking

To double check that everything was indeed patched, run the above command again. This should result in rsync not transferring any files because they are already updated. So, you’ll have the following:

me@mycomp:~$ pwd /var me@mycomp:~$ rsync -rcv webpatch/ www/webapp/ building file list … done sent 136 bytes received 38 bytes 348.00 bytes/sec total size is 64 speedup is 0.37

Hope this is helpful. Happy patching!

 

Got something to say?

  Textile Help