I think that every person who uses several computers, sooner or later there was a need to synchronize data between them.
In my case, the data was: notes (created in the excellent
ZIM tree editor), messenger logs (
Pidgin uses a great log format, very convenient for synchronization), program settings (any Linux user will not only agree that over time, the configuration files acquire the value of gold :)), as well as small and not very bash scripts accumulated over several years.
In this guide, I will explain how I solved the problems of synchronization, protection, and recovery in unforeseen situations of this data. Of course, these solutions are not universal, not final (they were developed over several years and may still change many times), but for some people they are primitive, but at the moment they meet all my requirements and, in my opinion worthy of publication. I hope someone will find here at least something useful for yourself! :)
So, let's begin. I divided the article into several parts, namely:
')
1. Statement of the problem
2. Version control of important files
3. Data protection
4. Install portable programs for Windows
5. Backup data
6. Combining all actions into one
Formulation of the problemA long time ago, I created a folder with a very thoughtful name,
saves, and began to put files there that were more or less important to me. In the case of documents, this was quite convenient, but if the file was required to be in a certain place (for example, the program's configuration file), then a copy of it got there, which was not entirely good.
After becoming acquainted with Linux and its file systems, such configuration files were moved to the place of their copy, and the soft link was placed in the right place.
Just got there:
* The file with passwords in the
keepass format (Linux version of the program -
KeePassX )
* Address book in .vcf format
* ZIM Editor Notes
* Bash (and other) scripts
* As well as a lot of other and small things.
After I had two computers (a working and a home laptop, Debian Etch was installed on both), it became necessary to have exact copies of this folder on both computers and to synchronize the changes made.
Over time, a Nokia N800 tablet and a Windows computer were added to the list, which I visit once a week, but this does not eliminate the need to have the same greasemonkey set of Firefox scripts as the rest.
Version control of important filesI decided that for the
saves folder
there would be not enough simple synchronization, but it is better to use some version control system that programmers love so much :)
After long comparisons, the choice fell on
Bazaar - a distributed version control system supported by the well-known Canonical company.
For it, I just had to create a script that performs the sequence of actions I need: it adds new files to the repository, offers to enter a comment for new changes (if they are, of course) and combine the changes with the parent repository (for N800 this is a computer, for a computer this a flash drive, and the flash drive has no parent repository).
Now I always have the same
saves folder on all computers and in case of any failures I can return to the previous version of any file.
Small addition:
Very often, the configuration files of the programs, apart from the actual configuration, contain any frequently changing parameters. For example, Firefox in the bookmarked file also stores the last time the bookmark was used, which changes each time a bookmark is used. It is clear that such data does not need synchronization, so I created a special
prepare_saves script that removes them from the files, as well as the materials of the developers who do this :).
Data protectionSince the
saves folder already contains enough data that I did not want to fall into the wrong hands about losing a flash drive, then this is the time to think about protecting it.
Thanks to Habra I learned about the program
TrueCrypt . With its help, I created a 200 MB file container with the NTFS file system on the flash drive (why NTFS is the one in the next section) and moved the
saves folder
there . Since in this case, the purpose of encryption is not protection from the FSB, but simply from getting the flash drive in the wrong hands, the password protection was enough.
Hmm ... such an important question, but there is nothing more to say :)
Installing portable programs for WindowsSince sometimes I still have to use Windows computers, the
PortableApps.org site has become a real find for me. Favorite Firefox and Pidgin, as well as some other programs, have firmly taken their place on the protected flash drive section.
Since the partition has the NTFS file system, I easily repeated the trick with replacing the configuration files with links to the corresponding files in the
saves folder.
Data backupOnce such a plane has been created, again it is a pity to lose it on the street. For backup (as well as synchronization), the good old
Unison was connected, which can do everything if it is properly configured.
Three profiles have been created for it:
* Backup all data on the unprotected part of the flash drive (excluding the encrypted file container)
* Backup all protected data (excluding
saves folder)
* Pidgin log synchronization
Since Unison does two-way synchronization, now, in order to write the file to the USB flash drive, I first write it to the backup directory (as if paradoxical as it sounds), and if necessary I start the synchronization procedure.
Combining all actions into oneNow the simplest thing is to write a script that will combine all the steps together. His algorithm is very simple:
1. Mount the protected section of the flash drive
2. Synchronize Pidgin logs
3. Synchronize the unprotected part of the flash drive
4. Synchronize the protected part of the flash drive
5. Run
prepare_saves for
saves on a flash drive
6. Zamitit saves changes on the flash drive
7. Run
prepare_saves for
saves on disk.
8. Save the changes on the disk and send them to the USB flash drive.
9. Unmount protected flash drive partition
Now, when you connect a flash drive to a computer, just click on one tab, enter the password to access the protected container, enter, if necessary, comment on the changes and ... understand that you spent a lot of time on what other people do not even think about :)
If someone wants to look at the source of any of my scripts, or just ask questions - welcome! I will be only glad to answer and help :)