I use rsync to move changes in my data between two computers. I do backup of data dir from PC2 to usb stick and than I insert usb stick to PC1 and run rsync to update data dir on PC1 according to data dir stored in usb stick. I use extra cute tiny flash 16Gb that i like so much. Data become heavier than 16Gb.
I always used this rsync command:
from=/home/y/data;to=/media/y/16g_flash/_backup_data/; rsync -av --delete $from $to
It deleted files from my usb flash that I've deleted on my PC. And it added new files, or updated files according to last modify time.
Now Data become heavier than space on my usb stick. **I like my 16Gb usb stick and wish to solve my problem with my hands and your advice**, without using another stick 256Gb for example.
The solution I can see is to copy only updated files and use text file with list of files (permissions, and last modify time) and use it for compare which files were deleted, updated, added. Steps are like these:
0. I copy my data dir: /home/y/data to both my PC: PC1 and PC2. So I start with same files list on different pc.
1. I store list of files to my usb stick to /media/y/16g_flash/pc1_data.txt and /media/y/16g_flash/pc2_data.txt. And these files are same from start.
2. I work on my PC2: delete some files, update, create new files. So data dir on my PC2 becomes truth, but data dir on my PC1 becomes not actual and needs to update.
3. I run rsync on PC2 to just copy new files and copy updated files to usb stick. And also I save new file list of my PC2 to /media/y/16g_flash/pc2_data.txt . This list of files is actual, because it was modified later than file /media/y/16g_flash/pc1_data.txt . So here, my usb stick just contains some files I've changed, and also contains "snapshot" of file list of data dir on my PC2.
4. I come to PC1 and run rsync to copy new files and update files that were updated from usb stick to PC1. And also I delete files that not exist in /media/y/16g_flash/pc2_data.txt because it means I've deleted them from PC2. And finally I have synchronized data dir on PC1.
This saves me from need to store all my files to USB. I just store "one last transaction":
- new and updated files
- and current list of files.
This may use just 100Mb of space on my usb stick instead of 20Gb that my data dir is using.
Is it possible with rsync?
I am not sure, how to do rsync comparing my data dir with just list of files in file /media/y/16g_flash/pc1_data.txt ? Also I am not sure how to remove old files on my PC1 if those files not exist in list /media/y/16g_flash/pc2_data.txt - does rsync do that, or I need to type bash script?
Asked by youni
(100 rep)
Sep 26, 2023, 05:28 PM
Last activity: Sep 27, 2023, 11:22 AM
Last activity: Sep 27, 2023, 11:22 AM