Synchronize files between a laptop and desktop PC

Laptop Repair Made Easy

Laptop Repair Made Easy

Get Instant Access

If you have two computers you might want to synchronize data between the two. For example, if you have a laptop, you might want to transfer the files in your Documents folder to the main PC (and vice versa). You

)t)S.ZZt>ZttY:2Z 1HI!+ l'-ïqgvQmigmwqw___.;!1>= 4dXZZZZZZZ

] 2>!ZZZ#X1N1 I = = gwoX2oooEnnvWvlimmmwXnn,JvV : iii=i.__-ÏSZZZZZZX

)S'XZ#2XM#a%+= _uZXXXSS-2SoonvWvIIIlilHWriii¥ZZX=onovn: = , "3Z-3ZZXZX

] SZZZZla | F< ; + _qiMiZ#Z2XXXZoonnnw I Iv 11 i iÛQWHH[nZXX = = = □ = = > Ifi^f

] s':z Z ##2o#-i#iïfy.UMi\tt#2 Z-Zix'ss n n wn.W 11111 i i i BaQHit1 Z Zfe= = n n , d XZX 2 2 X ] #cHÛ2 = mi QmmHm##XXXXZonnn Wv 11 v 11 i i i iSiHinriiyiiX)iX-=no= KZZMZ

] Ziiii iiiSniHBi inklmWmmi'i'ZZSZZonvVvv 1111111 i iSBWH^i'ZZZX-=nri> jZ'XXZXZ ] 1iF UiQdWBHmmiXXXSZnoZnnvv1111111 i iSBH[nm#ZZ>!X-=nv> uXZXZXX

] immBmpHmiE daBBmrnio li TX+XVM fil1111111iQWZVT ! ! ! ! IXoXoWV JZXXZÏSiX

] imniWmWm#> iK=3HrnBnriWZX 11 | | ZmHHO.viÛli i iH8X\U.îa_<.___a: : : : W .dZXXXKOT

] tïiWmBmBHZQWv . UmmP4dSz ! 1H !. iXgaSOMXriv 1H - 1 Xe l = vu 1 !'" ' + ! ! o i | = = S|XX#X ] iriHniHEiHrnnizwniQSrnsiXn 1 loi!VguiqgBXnmû E lnvme E w -ia3Hs%'_. ! 1; Ivvvo jXïiïX:XXS^S ] HmHmHmHBrriqo immmmovZZflon 1 S#mmliWlTicl-Xv i = >■> llnnn ! e3==v+%===X= ] X5ÎËXSSSSS ] BWmHBHBHHmmdnHmflmXXonsmBsQssaomXXovim=nXaa = = X#XZXS?X^KXs>,VoXSES2SSS2 ] HmH&HiïiHBBWWpciiïiHiïFÏZXSn wv 11 InqqujmZov iHXon = 3#mHmmHHmmZïKxj= lUXSS2S22a£É ] WmWmHBHBHT?îimmMiïiZXovViÛHmvv¥YVXZViQ!ÎS:== !o = = iiHgieHm?K:= = dSo22.Z2oZZ£2 ] BWBH?Yli¥XvJ$>»mmm#[email protected]!Wi'X = = vd ¡nZoooZooo ') Y ! = = = dimw=ns.3BBiîi#eOZmiowoXoonvliii iQmm#Xanonvnri£;!îi'QH)ÎÎÏ:= = '' ; ; +1 =MMMlnn ) = = = = = = HQZonv3W#i'oiHHQil ! ! EXpliznuiiiHki3mZe ! " =n = X#mnïHÎ<=== =+++| | | !M ] = n v n 11 i Z-v i 1 ] [email protected] [= <$=X#mQtlm)iS:=> = + —+= = ') = = nvvi<l+! ! +w33##X2siVdXff#mXovQri]mmmijJW=aaaa=xSx#=++++= = JqStivv;! aX> = uISzàonoXX:xSxïlIiliaaa#Z#ji#=-;==Z;ïH#Z = î 1 : fugs? ] maa%F~ «iV5 + <(-!S.XXZ#ZZ'XXS00VliQ#mi'riZX:jib====ZiïX=ï~ : = ; =

]SiE"~ : | : i : <2 43SX##ZXoiwi%1 i aHaZX.ZX = nwno IT

Figure 3.41: A photo rendered by asciiview (see Tip 268, on the preceding page)

could do this manually, by creating a network share (see Tip 28, on page 84 for details), but it's much better to do it automatically, with just a single click.

There are a variety of ways of synchronizing files under Ubuntu and, indeed, this is the kind of task that Linux excels in. However, perhaps the most fuss-free method is to use a program called Unison (or, actually, Unison GTK, which adds a graphical front-end to the Unison command-line program; throughout I refer to the whole thing at Unison, for simplicity). Unison uses built-in Linux tools to sync files but hides everything behind a friendly user-interface.

Below are the steps required to sync the Documents folders on two separate computers using Unison. Before following these steps, follow the instructions in Tip 26, on page 83, which explain how to ensure Ubuntu always has the correct time. Follow the steps on both computers. This is essential because synchronization will fail otherwise.

These instructions make reference to a desktop PC and laptop computer, but could be any two computers capable of running Ubuntu (or indeed any computer with Linux installed that can run Unison):

Figure 3.42: Resolving a file clash in Unison (see Tip 269, on page 306)

1. On the desktop PC, use Synaptic to install the unison-gtk package. Meanwhile, on the laptop, use Synaptic to install the openssh-server and unison-gtk packages. As you might have guessed, Unison uses SSH in the background to provide the file transfer conduit. If you want to learn more about SSH, see Tip 190, on page 228.

2. once installed on the desktop pC, Unison can be found on the Applications ^ Accessories menu. When it starts a wizard will walk you through creating an initial profile. The first step is to enter the folder on the desktop pC that you want to synchronize. Click the Browse button and then locate your Documents folder. Click OK to close the file browsing dialog and OK again to move onto the next step of the wizard in Unison.

3. In the next step, you must tell Unison which folder you want to synchronize with on the laptop. in the Directory text field, type Documents again. There's no need to precede it with /home/username because Unison will automatically log into the laptop's /home/username folder each time it synchronizes.

4. Click the SSH radio button. You'll now need to find the IP address of the laptop. This can be done by moving over to it, right-clicking its NetworkManager icon and selecting Connection Information. Then look in the dialog that appears for the line that reads IP Address.

Type what you see (four numbers separated by dots) into the Host text field back on the desktop PC.

5. In the User text field, still on the desktop PC, type the login name you use on the laptop. Then click the OK button.

6. You'll immediately be told that the laptop computer is being contacted. Then a dialog box will pop-up telling you that the "authenticity of host can't be established". This is fine. Just type yes to continue and hit OK.

7. You'll then be prompted for the login password on the laptop. Type it and then click OK.

8. Following this you'll see a scary-looking warning dialog box saying that "no archives were found for these roots". Don't worry. This appears because this is the first time you've synchronized. Once you click OK, Unison will detect the files both on the desktop PC and the laptop (it's worth pointing out that you won't see any sign of Unison running on the laptop, nor do you have to do anything on the laptop—Unison runs automatically in the background).

9. After a few minutes the program window on the desktop PC will indicate the file differences between the two folders. The Path heading will show the file in question, and under the Action heading will be the "direction of travel", indicated by an arrow—if the arrow points left, the file will be transferred to the desktop PC from the laptop. If it points right, the file will be transfered from the desktop PC to the laptop. If you don't want to synchronize a particular file or folder, select it and click the Skip button on the toolbar. However, assuming you're happy with everything, click the Go button on the toolbar. The files will then be copied across. When Unison has finished (look at the status bar in the bottom left of the Unison window, and the Status heading in the list of files), you can close the program window.

And that's all there is to it. Following this, you should run Unison on the desktop PC every time you want to sync the Documents folders on the two computers, such as when you get home from work. When Unison starts, just select default from the list.

Note that Unison always updates older files when synchronizing. For example, if you started a file on your desktop PC, transferred it to your laptop using Unison, and edited it while out and about, Unison will automatically overwrite the older file on the desktop PC with the updated version. This makes sense, of course. If the situation arises that the file gets updated on both machines between synchronizations, a question mark will appear alongside the file when you come to synchronize— see Figure 3.42, on page 308 for an example—and it won't get automatically copied across. You'll then have to manually intervene to decide which to overwrite—the copy on the desktop PC or the copy on the laptop. Click the Right to Left toolbar button to overwrite the file on the desktop PC, or the Left to Right button to overwrite the file on the laptop. Of course, it might be simpler just to manually copy the file across in this case—because SSH is providing the connection Unison uses to transfer files, you can use Nautilus to browse the files on the remote computer via an SFTP connection. To learn how, see the closing paragraphs of Tip 190, on page 228.

You can create additional profiles to sync other folders too—just click the Create New Profile button in Unison's startup program window, type a name for the profile when prompted, and then double-click its entry in the list to start working through the wizard again. I find it useful to synchronize the Desktop folder on both machines because I tend to temporarily store a lot of files there. Don't choose to sync your entire /home folder—hidden files are copied across too by Unison, and hidden files within your /home folder contain program configuration files unique to each computer. Upon synchronization there would be some almighty file clashes, and the likelihood of the login accounts on both systems getting damaged beyond repair because of mangled configuration files is high.

It's worth noting that you don't necessarily have to sync between two computers. You can also sync between a folder on a removable storage devices and one on the computer's hard disk, or even just another folder on the same computer. Just select the Local radio button in the step above when you chose SSH and fill-in the details appropriately.

Was this article helpful?

0 0

Post a comment