LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to easily copy changes in one linux filesystem to another ? (http://www.linuxquestions.org/questions/linux-general-1/how-to-easily-copy-changes-in-one-linux-filesystem-to-another-4175446614/)

grgsaliba 01-21-2013 01:01 PM

How to easily copy changes in one linux filesystem to another ?
 
Hi,

I'm using linux (debian based distro) in embedded applications but my question is actually quite generic.

So I start out with some basic linux installation, install new programs, add my own scripts and customize various files according to the application. We then ship the first prototype devices and following customer feedback need to do some changes.

My problem is how can I easily send changes to the customer - without having to send him a full 4GB image for every update ?

The required updates might require changes to existing files, as well as addition or deletion of files in several different directories.

The best way I have found so far is to load the updated image on a prototype device, copy the entire installation to a local folder on my workstation using scp. Then I delete all the major directories in which I know there were no changes to reduce the total size as much as possible. I then send the resulting directory to the customer together with a batch file that runs scp to copy these files over to the target device.

This works fine but there are a number of problems:
- the size of the files to transfer is still larger than really required.
- manual deletion of the unchanged folders is a tedious process and mistakes are easy.
- deletion of files of the target installation is not prossible - only addition and updates are possible.

Is there any way to sort of create a "diff" of two filesystems and "automatically" generate some kind of patch that makes the target filesystem identical to the source ?

Thanks,
George

kbp 01-21-2013 07:05 PM

How does the customer usually update the device and do they want to change their process ? .. maybe they could set up a local copy of the filesystem and you/they could rsync from yours to theirs over the Internet?

grgsaliba 01-22-2013 02:49 PM

rsync is a good idea but I would prefer to have some kind of update file that can be used offline and stored for later use.

thanks

suicidaleggroll 01-22-2013 03:51 PM

What if you use rsync -avn --delete and dump the output to a log file. The -n tells rsync to do a dry run, meaning nothing is modified on the source or destination. Instead rsync prints out what it WOULD have done. You can then write a simple script to turn this log into a patch and gather all of the files it needs.

For example:
Code:

$ ls -l original/*
-rw-rw-r-- 1 user user  12 Jan 22 13:38 original/file1
-rw-rw-r-- 1 user user    6 Jan 22 13:38 original/file2
-rw-rw-r-- 1 user user    8 Jan 22 13:38 original/file3

original/dir1:
total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:37 file4
-rw-rw-r-- 1 user user 0 Jan 22 13:37 file5

original/dir2:
total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:38 file6

original/dir3:
total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:38 file7
-rw-rw-r-- 1 user user 0 Jan 22 13:38 file8

original/dir4:
total 0
$
$ ls -l modded/*
-rw-rw-r-- 1 user user    6 Jan 22 13:39 modded/file1
-rw-rw-r-- 1 user user  19 Jan 22 13:39 modded/file2
-rw-rw-r-- 1 user user    8 Jan 22 13:38 modded/file3

modded/dir1:
total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:37 file5

modded/dir2:
total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:38 file6

modded/dir4:
total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:39 newfile

You can see that in the "modded" directory, I modified file1 and file2, removed dir1/file4, removed dir3 entirely, and added dir4/newfile
Code:

$ rsync -avn --delete modded/ original/
sending incremental file list
./
deleting dir3/file8
deleting dir3/file7
deleting dir3/
file1
file2
dir1/
deleting dir1/file4
dir4/
dir4/newfile

sent 231 bytes  received 33 bytes  528.00 bytes/sec
total size is 33  speedup is 0.12 (DRY RUN)

The output is pretty much a list of instructions for your script.

grgsaliba 01-22-2013 05:34 PM

That's one clever idea! ...it might be just what I need actually.

Most probably I will need to send one such update this week so I will try this out and let you know how it goes.

Thanks for the detailed reply!


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