कुछ समय पहले, मुझे rsyncएक स्क्रिप्ट के लिए आउटपुट को समझने की आवश्यकता थी जो मैं लिख रहा था। उस स्क्रिप्ट को लिखने की प्रक्रिया के दौरान मैंने चारों ओर गुगली की और ऊपर जो @mit लिखा था वह आया । मैंने उस सूचना का उपयोग किया, साथ ही साथ अन्य स्रोतों से दस्तावेज़ीकरण, बिट्स फ़्लैग पर अपना प्राइमर बनाने के rsyncलिए और सभी कार्यों के लिए आउटपुट फ़्लैग बिट्स को कैसे प्राप्त किया जाए (यह डिफ़ॉल्ट रूप से ऐसा नहीं करता है)।
मैं उस जानकारी को यहाँ इस उम्मीद में पोस्ट कर रहा हूँ कि यह दूसरों को (जो मेरे जैसे) खोज के माध्यम से इस पेज पर आने में मदद करती है और इसके बेहतर स्पष्टीकरण की आवश्यकता है rsync।
के संयोजन के साथ --itemize-changesझंडा और-vvv ध्वज, rsyncहम सभी फाइल सिस्टम परिवर्तन है कि स्रोत निर्देशिका में पहचान की गई है जब लक्ष्य निर्देशिका की तुलना की विस्तृत उत्पादन देता है। rsyncतब जो झंडे का उत्पादन किया जाता है, उसे यह निर्धारित करने के लिए डिकोड किया जा सकता है कि क्या बदल गया है। प्रत्येक बिट के अर्थ को डीकोड करने के लिए, निम्न तालिका का उपयोग करें।
प्रत्येक बिट स्थिति और rsyncआउटपुट में मूल्य की व्याख्या :
YXcstpoguax path/to/file
|||||||||||
||||||||||╰- x: The extended attribute information changed
|||||||||╰-- a: The ACL information changed
||||||||╰--- u: The u slot is reserved for future use
|||||||╰---- g: Group is different
||||||╰----- o: Owner is different
|||||╰------ p: Permission are different
||||╰------- t: Modification time is different
|||╰-------- s: Size is different
||╰--------- c: Different checksum (for regular files), or
|| changed value (for symlinks, devices, and special files)
|╰---------- the file type:
| f: for a file,
| d: for a directory,
| L: for a symlink,
| D: for a device,
| S: for a special file (e.g. named sockets and fifos)
╰----------- the type of update being done::
<: file is being transferred to the remote host (sent)
>: file is being transferred to the local host (received)
c: local change/creation for the item, such as:
- the creation of a directory
- the changing of a symlink,
- etc.
h: the item is a hard link to another item (requires
--hard-links).
.: the item is not being updated (though it might have
attributes that are being modified)
*: means that the rest of the itemized-output area contains
a message (e.g. "deleting")
विभिन्न परिदृश्यों के लिए rsync से कुछ उदाहरण आउटपुट:
>f+++++++++ some/dir/new-file.txt
.f....og..x some/dir/existing-file-with-changed-owner-and-group.txt
.f........x some/dir/existing-file-with-changed-unnamed-attribute.txt
>f...p....x some/dir/existing-file-with-changed-permissions.txt
>f..t..g..x some/dir/existing-file-with-changed-time-and-group.txt
>f.s......x some/dir/existing-file-with-changed-size.txt
>f.st.....x some/dir/existing-file-with-changed-size-and-time-stamp.txt
cd+++++++++ some/dir/new-directory/
.d....og... some/dir/existing-directory-with-changed-owner-and-group/
.d..t...... some/dir/existing-directory-with-different-time-stamp/
कैप्चरिंग rsyncआउटपुट (बिट झंडे पर केंद्रित):
मेरे प्रयोग में, दोनों --itemize-changesध्वज और-vvv ध्वज को पाने के लिए की जरूरत है rsyncउत्पादन के लिए के लिए एक प्रवेश सभी फाइल सिस्टम बदल जाता है। ट्रिपल वर्बोज़ ( -vvv) ध्वज के बिना , मैं सूचीबद्ध निर्देशिका, लिंक और डिवाइस परिवर्तन नहीं देख रहा था। यह rsync के आपके संस्करण के साथ प्रयोग करने के लायक है, यह सुनिश्चित करने के लिए कि यह वह सब देख रहा है और आपकी अपेक्षा के अनुरूप है।
इस तकनीक का एक उपयोगी उपयोग --dry-runध्वज को कमांड में जोड़ना और परिवर्तन सूची को इकट्ठा करना है, जैसा कि rsync द्वारा निर्धारित किया गया है, एक चर में (बिना किसी परिवर्तन के) ताकि आप सूची में कुछ प्रसंस्करण स्वयं कर सकें। एक चर में आउटपुट को कैप्चर करने पर निम्न जैसा कुछ होगा:
file_system_changes=$(rsync --archive --acls --xattrs \
--checksum --dry-run \
--itemize-changes -vvv \
"/some/source-path/" \
"/some/destination-path/" \
| grep -E '^(\.|>|<|c|h|\*).......... .')
ऊपर दिए गए उदाहरण में, (स्टडआउट) आउटपुट को स्टड के माध्यम से rsyncरीडायरेक्ट किया गया है, grepइसलिए हम केवल उन पंक्तियों को अलग कर सकते हैं जिनमें बिट्स फ़्लैग होते हैं।
कैप्चर किए गए आउटपुट को संसाधित करना:
चर की सामग्री को बाद में उपयोग के लिए लॉग इन किया जा सकता है या तुरंत ब्याज की वस्तुओं के लिए पुनरावृत्त किया जा सकता है। इस पटकथा का उपयोग मैं उस पटकथा में करता हूं, जिसके बारे में मैंने और अधिक शोध किया है rsync। आप नई फ़ाइलों को अलग करने के लिए कैप्चर किए गए आउटपुट को पोस्ट-प्रोसेसिंग करने के लिए स्क्रिप्ट ( https://github.com/jmmitchell/movestough ) पर देख सकते हैं , डुप्लिकेट फ़ाइलें (एक ही नाम, एक ही सामग्री), फ़ाइल टकराव (एक ही नाम, अलग-अलग) सामग्री), साथ ही उपनिर्देशिका संरचनाओं में परिवर्तन।