<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: m4r4v</title>
    <description>The latest articles on DEV Community by m4r4v (@m4r4v).</description>
    <link>https://dev.to/m4r4v</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F426513%2F96daf66a-8f40-4716-88bb-24c8646fe193.png</url>
      <title>DEV Community: m4r4v</title>
      <link>https://dev.to/m4r4v</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/m4r4v"/>
    <language>en</language>
    <item>
      <title>APIOLOGY a PHP API light framework</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Fri, 22 Sep 2023 23:03:35 +0000</pubDate>
      <link>https://dev.to/m4r4v/apiology-a-php-api-light-framework-i78</link>
      <guid>https://dev.to/m4r4v/apiology-a-php-api-light-framework-i78</guid>
      <description>&lt;p&gt;Just released a php api framework, to make things easy in order to handle backend requests in any host using php.&lt;/p&gt;

&lt;p&gt;It can be found &lt;a href="https://github.com/m4r4v/apiology"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What I loved about it is the way it can handle http headers, including Origin, Methods and Authorization.&lt;/p&gt;

&lt;p&gt;At the moment it just have BasicAuth and ApiKey available.&lt;/p&gt;

&lt;p&gt;The versioning works great, no need to reinvent the wheel. To create a version is as easy as the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add version name and status to settings&lt;/li&gt;
&lt;li&gt;Create a folder with the Version Number i.e: v2&lt;/li&gt;
&lt;li&gt;Copy resources.php from v1 folder and paste it inside the new version folder.&lt;/li&gt;
&lt;li&gt;Use a Namespace according to the version i.e.: Apiology\Api\Resources\V2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for testing purposes, it has instruction on how to run a docker container, instructions and be read &lt;a href="https://github.com/m4r4v/apiology#readme"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Love to have a review about it and improvements are always welcome.&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

</description>
      <category>api</category>
      <category>php</category>
      <category>backend</category>
      <category>docker</category>
    </item>
    <item>
      <title>How to access android files from linux terminal</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Fri, 22 Jan 2021 18:08:17 +0000</pubDate>
      <link>https://dev.to/m4r4v/how-to-access-android-files-from-linux-terminal-h5</link>
      <guid>https://dev.to/m4r4v/how-to-access-android-files-from-linux-terminal-h5</guid>
      <description>&lt;p&gt;Hi there,&lt;br&gt;
If you ever wanted to know how to access our android phone files from terminal, without using any third party app and just with a USB cable and GNome, here is how:&lt;/p&gt;

&lt;p&gt;We need to check the GNOME Virtual file system (gfvs) to see it is available.&lt;/p&gt;

&lt;p&gt;run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ls /run/user/1000/gvfs/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You will get an Media Transfer Protocol (mtp), for more about this, check this link: &lt;a href="https://wiki.debian.org/mtp"&gt;MTP&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;'mtp:host=PHONE_MANUFACTURER_AND_MODEL'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now use it as it would be any other directory on your system&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd /run/user/1000/gvfs/mtp:host=PHONE_MANUFACTURER_AND_MODEL&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Done, you can access your phone directory and do whaterver you want.&lt;/p&gt;

&lt;p&gt;Bye!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>android</category>
      <category>bash</category>
    </item>
    <item>
      <title>How to fix audio from ubuntu 20.04 focal fossa "dummy-output"</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Fri, 08 Jan 2021 14:23:51 +0000</pubDate>
      <link>https://dev.to/m4r4v/how-to-fix-audio-from-ubuntu-20-04-focal-fossa-dummy-output-32jh</link>
      <guid>https://dev.to/m4r4v/how-to-fix-audio-from-ubuntu-20-04-focal-fossa-dummy-output-32jh</guid>
      <description>&lt;p&gt;Hello, I came across an issue from the latest update. I couldn't listen to any sound from my earphones it was only showing dummy-output as the default Output Device, which it was absolutely not right.&lt;/p&gt;

&lt;p&gt;To fix it, I did the following (It must be done as root, so used sudo for it):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo vim /etc/modprobe.d/alsa-base.conf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;At the end of the file I added:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;options snd-hda-intel dmic_detect=0 &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then I did:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo vim /etc/modprobe.d/blacklist.conf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;At the end of the file I added:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;blacklist snd_soc_skl&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I didn't even had to reboot, but, somehow it is always good to reboot the system after editing configuration files.&lt;/p&gt;

&lt;p&gt;Note: I am using an acer swift laptop (intel) so please make sure that this works for you. I also use vim but it can also be done in your text editor of your preference&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Bash Script to Install FireFoxDeveloper Edition</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Fri, 11 Sep 2020 15:49:33 +0000</pubDate>
      <link>https://dev.to/m4r4v/bash-script-to-install-firefoxdeveloper-edition-2mfi</link>
      <guid>https://dev.to/m4r4v/bash-script-to-install-firefoxdeveloper-edition-2mfi</guid>
      <description>&lt;p&gt;I am a big fan of &lt;a href="https://www.mozilla.org/en-US/firefox/new/"&gt;firefox&lt;/a&gt; and since it came out with the finest distribution for developers &lt;a href="https://www.mozilla.org/en-US/firefox/developer/"&gt;firefox developer edition&lt;/a&gt; it really made my web dev life easie.&lt;/p&gt;

&lt;p&gt;Installing it in Linux is not that easy as it is in windows or in mac, but that's the fun about linux hehe, at least it is for me.&lt;/p&gt;

&lt;p&gt;I've seen many articles and tutorials where people explain how to install it, but most of them it just get rid of firefox and replace it with the firefox developer edition. I just like to have both browsers the released and stable version and the unstable developer version.&lt;/p&gt;

&lt;p&gt;So far I've been doing the installation manually and every time they have a new release I had to run the same command line again and again, got boring to me and I just created my automated script for it to do it on its own.&lt;/p&gt;

&lt;p&gt;I uploaded the script to my github &lt;a href="https://github.com/gorka-lab/update-firefox-developer-linux"&gt;update-firefox-developer-linux&lt;/a&gt; for everyone to use it.&lt;/p&gt;

&lt;p&gt;let me show it to you here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

# Source reference: https://www.rogerpence.com/posts/a-bash-script-to-install-firefox-dev-edition

function installFFDE {
    cd ~/Downloads
    ffdFile= firefox-*.tar.bz2
    tar -xvf $ffdFile
    mv firefox firefox-developer
    sudo cp -r firefox-developer/ /opt/
    echo "files were copied into /opt/"
    rm -r firefox-developer &amp;amp;&amp;amp; rm -r $ffdFile
    echo "All files were removed, your're good to go"
}

function downloadAndInstallFFDE {
    curl -o releases.txt https://download-installer.cdn.mozilla.net/pub/devedition/releases/
    echo "Downloaded..."
    latest=$(grep -o '[0-9][0-9]\.[0-9][a-z][0-9]' releases.txt | tail -1)  
    echo "getting latest release...\nthe latest release is:\nfirefox-$latest.tar.bz2" 
    echo "got latest version"
    ffdFile=firefox-$latest.tar.bz2
    rm releases.txt
    curl -o $ffdFile https://download-installer.cdn.mozilla.net/pub/devedition/releases/$latest/linux-x86_64/en-US/$ffdFile
    echo "got latest version. Proceeding to install it"
    tar -xvf $ffdFile
    mv firefox firefox-developer
    sudo cp -r firefox-developer/ /opt/
    echo "files were copied into /opt/"
    rm -r firefox-developer &amp;amp;&amp;amp; rm -r $ffdFile
    echo "All files were removed, your're good to go"
}

FILE=firefox-*.tar.bz2

if [ -e $FILE ]; then
    installFFDE
else 
    echo "installation file does not exists, will start downloading it now..."
    downloadAndInstallFFDE
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;hope you all like it, let me know any improvement suggestions and happy to help.&lt;/p&gt;

&lt;p&gt;Don't forget to Follow, ❤️ or 🦄&lt;br&gt;
Happy Coding!!!&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
    </item>
    <item>
      <title>Level 1 Completed</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Wed, 29 Jul 2020 23:47:13 +0000</pubDate>
      <link>https://dev.to/m4r4v/level-1-completed-4bi4</link>
      <guid>https://dev.to/m4r4v/level-1-completed-4bi4</guid>
      <description>&lt;p&gt;Hi everyone,&lt;br&gt;
I got the foobar challenge and just wanted to share with you all that I just completed level 1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fueylqwyrolewgc83shd2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fueylqwyrolewgc83shd2.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was a nice challenge, I have no idea why I love to challenge myself.&lt;/p&gt;

&lt;p&gt;If you have done this challenge, please share your experience&lt;/p&gt;

&lt;p&gt;Take care everyone, stay safe and happy coding!!!&lt;/p&gt;

</description>
      <category>challenge</category>
    </item>
    <item>
      <title>rsync - 10 examples in 11 days (Day 11)</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Sun, 26 Jul 2020 19:36:32 +0000</pubDate>
      <link>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-11-69</link>
      <guid>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-11-69</guid>
      <description>&lt;h1&gt;
  
  
  Day 11
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;10 examples in 11 days&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Log Files
&lt;/h2&gt;

&lt;p&gt;Well it seems we have come to the end of the series. Have in mind that &lt;strong&gt;rsync&lt;/strong&gt; has a lot more to offer so please read the man page to get and use the best of &lt;strong&gt;rsync&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I can't end this series without talking about a great option. It's about the &lt;strong&gt;--log-file=FILE&lt;/strong&gt; option.&lt;/p&gt;

&lt;p&gt;Sometimes you may want or need a log file, let's say you want to check out what was done, or like what happened to me, our manager always made us send every morning an email with the log of all sync done the day before (we made a script for that hehe). But let's face it, it's a good practice to create a log file almost for everything (I do it all the time).&lt;/p&gt;

&lt;p&gt;So, having &lt;strong&gt;rsync&lt;/strong&gt; create its own log file after every sync huh?, yup, it's as easy as it sounds, let me show you what the syntax can look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rsync [--options] [Source] [Destination] --log-file=[Where the log file will be stored]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you read &lt;a href="https://dev.to/jmr_code_social/rsync-10-examples-in-11-days-day-10-4c0i"&gt;Day 10&lt;/a&gt; great and if you haven't, please do because today's option will use a lot of the arguments shown there. I will still use the folders I've been using so far &lt;strong&gt;Users&lt;/strong&gt; and &lt;strong&gt;Sync&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now, to get the picture, I will do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I will empty out all files inside Sync&lt;/li&gt;
&lt;li&gt;I will run rsync with the log file option&lt;/li&gt;
&lt;li&gt;I will show what the log file looks like
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rm -r Sync/ &amp;amp;&amp;amp; rsync -a Users/ Sync --log-file=Sync/logfile.txt &amp;amp;&amp;amp; ls -la Sync/ &amp;amp;&amp;amp; cat Sync/logfile.txt
total 16
drwxrwxr-x  2 iamgroot iamgroot 4096 jul 26 13:48 .
drwxrwxr-x 38 iamgroot iamgroot 4096 jul 26 02:15 ..
-rw-rw-r--  1 iamgroot iamgroot   30 jul 26 13:48 file1.txt
-rw-r--r--  1 iamgroot iamgroot  217 jul 26 14:16 logfile.txt
2020/07/26 14:16:35 [13004] building file list
2020/07/26 14:16:35 [13004] .d..t...... ./
2020/07/26 14:16:35 [13004] &amp;gt;f+++++++++ file1.txt
2020/07/26 14:16:35 [13004] sent 163 bytes  received 43 bytes  total size 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see what the &lt;em&gt;logfile.txt&lt;/em&gt; looks like, let's go through it&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2020/07/26 14:16:35 [13004] building file list&lt;/code&gt;: Rsync always shows this when it starts&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2020/07/26 14:16:35 [13004] .d..t...... ./&lt;/code&gt; The directory of the source using the &lt;strong&gt;&lt;em&gt;-i&lt;/em&gt;&lt;/strong&gt; option&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2020/07/26 14:16:35 [13004] &amp;gt;f+++++++++ file1.txt&lt;/code&gt; The file sync displayed using the &lt;strong&gt;&lt;em&gt;-i&lt;/em&gt;&lt;/strong&gt; option&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2020/07/26 14:16:35 [13004] sent 163 bytes received 43 bytes total size 30&lt;/code&gt; End of the sync&lt;/p&gt;

&lt;p&gt;As I said, rsync log file uses by default the &lt;strong&gt;&lt;em&gt;-i&lt;/em&gt;&lt;/strong&gt; option that I explained in &lt;a href="https://dev.to/jmr_code_social/rsync-10-examples-in-11-days-day-10-4c0i"&gt;Day 10&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  But what if we want to add some different arguments to the log file?
&lt;/h3&gt;

&lt;p&gt;Well this is what I love about &lt;strong&gt;rsync&lt;/strong&gt;, it always gives us something else. In this case we have the &lt;strong&gt;--log-file-format&lt;/strong&gt; option. Is like the &lt;strong&gt;--out-format&lt;/strong&gt; but explicitly for the log file.&lt;/p&gt;

&lt;p&gt;Let's say I only want the length of the file in bytes, then we can use the &lt;strong&gt;%l&lt;/strong&gt; argument like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync -a Users/ Sync --log-file=Sync/logfile.txt --log-file-format='%l' &amp;amp;&amp;amp; cat Sync/logfile.txt
2020/07/26 14:23:52 [14572] building file list
2020/07/26 14:23:52 [14572] 4096
2020/07/26 14:23:52 [14572] 30
2020/07/26 14:23:52 [14572] sent 163 bytes  received 43 bytes  total size 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's compare what we had before and what we've got now:&lt;/p&gt;

&lt;p&gt;Before: &lt;code&gt;2020/07/26 14:16:35 [13004] .d..t...... ./&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now: &lt;code&gt;2020/07/26 14:23:52 [14572] 4096&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Before: &lt;code&gt;2020/07/26 14:16:35 [13004] &amp;gt;f+++++++++ file1.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now: &lt;code&gt;2020/07/26 14:23:52 [14572] 30&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The default options are &lt;strong&gt;%o %h [%a] %m (%u) %f %l", and a "%t [%p]"&lt;/strong&gt; and all the options available are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;option&lt;/th&gt;
&lt;th&gt;description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;%a&lt;/td&gt;
&lt;td&gt;the remote IP address (only available for a daemon)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%b&lt;/td&gt;
&lt;td&gt;the number of bytes actually transferred&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%B&lt;/td&gt;
&lt;td&gt;the permission bits of the file (e.g. rwxrwxrwt)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%c&lt;/td&gt;
&lt;td&gt;the total size of the block checksums received for the basis file (only when sending)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%C&lt;/td&gt;
&lt;td&gt;the full-file checksum if it is known for the file. For older rsync protocols/versions, the checksum was salted, and is thus not a useful value (and is not displayed when that is the case). For the checksum to output for a file, either the --checksum option must be in-effect or the file must have been transferred without a salted checksum being used. See the --checksum-choice option for a way to choose the algorithm.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%f&lt;/td&gt;
&lt;td&gt;the filename (long form on sender; no trailing "/")&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%G&lt;/td&gt;
&lt;td&gt;the gid of the file (decimal) or "DEFAULT"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%h&lt;/td&gt;
&lt;td&gt;the remote host name (only available for a daemon)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%i&lt;/td&gt;
&lt;td&gt;an itemized list of what is being updated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%l&lt;/td&gt;
&lt;td&gt;the length of the file in bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%L&lt;/td&gt;
&lt;td&gt;the string "-&amp;gt; SYMLINK", "=&amp;gt; HARDLINK", or "" (where SYMLINK or HARDLINK is a filename)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%m&lt;/td&gt;
&lt;td&gt;the module name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%M&lt;/td&gt;
&lt;td&gt;the last-modified time of the file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%n&lt;/td&gt;
&lt;td&gt;the filename (short form; trailing "/" on dir)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%o&lt;/td&gt;
&lt;td&gt;the operation, which is "send", "recv", or "del." (the latter includes the trailing period)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%p&lt;/td&gt;
&lt;td&gt;the process ID of this rsync session&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%P&lt;/td&gt;
&lt;td&gt;the module path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%t&lt;/td&gt;
&lt;td&gt;the current date time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%u&lt;/td&gt;
&lt;td&gt;the authenticated username or an empty string&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;%U&lt;/td&gt;
&lt;td&gt;the uid of the file (decimal)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now I will give you all a nice tip, like I did in &lt;a href="https://dev.to/jmr_code_social/rsync-10-examples-in-11-days-day-06-454o"&gt;Day 06&lt;/a&gt;, and I really suggest you do this if you work in a team. Add the logged user &lt;em&gt;$USER&lt;/em&gt; who is performing the sync and also the file that was sync. Let me show you how:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync -a Users/ Sync --log-file=Sync/logfile.txt --log-file-format='%i --File: %n -- User: '$USER &amp;amp;&amp;amp; cat Sync/logfile.txt
2020/07/26 14:33:03 [15332] building file list
2020/07/26 14:33:03 [15332] .d..t...... --File: ./ -- User: iamgroot
2020/07/26 14:33:03 [15332] &amp;gt;f+++++++++ --File: file1.txt -- User: iamgroot
2020/07/26 14:33:03 [15332] sent 163 bytes  received 43 bytes  total size 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Isn't this awesome?&lt;/p&gt;

&lt;p&gt;OK, that'll be it for today and this is the end of the &lt;strong&gt;rsync&lt;/strong&gt; series. I really hope you all enjoyed it. If you have any doubt don't hesitate asking me, will be more than happy to help.&lt;/p&gt;




&lt;p&gt;Thanks for reading, keep it safe!!&lt;/p&gt;

&lt;p&gt;Don't forget to Follow, ❤️ or 🦄&lt;/p&gt;

&lt;p&gt;&lt;code&gt;iamgroot@laptop:~$ exit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;👍&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>tutorial</category>
      <category>rsync</category>
    </item>
    <item>
      <title>rsync - 10 examples in 11 days (Day 10)</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Sun, 26 Jul 2020 06:10:09 +0000</pubDate>
      <link>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-10-4c0i</link>
      <guid>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-10-4c0i</guid>
      <description>&lt;h1&gt;
  
  
  Day 10
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;10 examples in 11 days&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Sync --i, --itemize-changes
&lt;/h2&gt;

&lt;p&gt;Now in &lt;strong&gt;Day 10&lt;/strong&gt; I will talk about a flag that can't be out of this series. I am talking about the &lt;strong&gt;-i&lt;/strong&gt; option.&lt;/p&gt;

&lt;p&gt;This option allows us to know what changes were made. This option comes very handy when it used along with the &lt;strong&gt;--dry-run&lt;/strong&gt; flag.&lt;/p&gt;

&lt;p&gt;Here is what the man page says about it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-i,--itemize-changes       output a change-summary for all updates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But how is the output will look like?&lt;/p&gt;

&lt;p&gt;Whenever we use the &lt;strong&gt;-i&lt;/strong&gt; we get a string of characters &lt;strong&gt;YXcstpoguax&lt;/strong&gt; (not all of them) on which each one has its own meaning:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;source: man rsync&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Y&lt;/strong&gt; and &lt;strong&gt;X&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Y/X&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;td&gt;Is the type of update&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;Is the file-type&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Y&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt;&lt;/td&gt;
&lt;td&gt;a file is being transferred to the remote host (sent)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;gt;&lt;/td&gt;
&lt;td&gt;a file is being transferred to the local host (received)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;c&lt;/td&gt;
&lt;td&gt;means that a local change/creation is occurring for the item (such as the creation of a directory or the changing of a symlink, etc.).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;h&lt;/td&gt;
&lt;td&gt;the item is a hard link to another item (requires--hard-links.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.&lt;/td&gt;
&lt;td&gt;the item is not being updated (though it might have attributes that are being modified)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;*&lt;/td&gt;
&lt;td&gt;means that the rest of the itemized-output area contains a message (e.g. "deleting")&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;X&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;f&lt;/td&gt;
&lt;td&gt;for a file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;d&lt;/td&gt;
&lt;td&gt;for a directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;L&lt;/td&gt;
&lt;td&gt;for a symlink&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;for a device&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;S&lt;/td&gt;
&lt;td&gt;for a special file (e.g. named sockets and fifos).&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Attributes &lt;strong&gt;cstpoguax&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attributes&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;c&lt;/td&gt;
&lt;td&gt;Means either that a regular file has a different checksum (requires --checksum) or that a symlink, device, or special file has a changed value. Note that if you are sending files to an rsync prior to 3.0.1, this change flag will be present only for checksum-differing regular files.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;s&lt;/td&gt;
&lt;td&gt;Means the size of a regular file is different and will be updated by the file transfer.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;t&lt;/td&gt;
&lt;td&gt;Means the modification time is different and is being updated to the sender’s value (requires --times). An alternate value of T means that the modification time will be set to the transfer time, which happens when a file/symlink/device is updated without --times and when a symlink is changed and the receiver can’t set its time.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p&lt;/td&gt;
&lt;td&gt;Means the permissions are different and are being updated to the sender’s value (requires --perms).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;o&lt;/td&gt;
&lt;td&gt;Means the owner is different and is being updated to the sender’s value (requires --owner and super-user privileges).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g&lt;/td&gt;
&lt;td&gt;Means the group is different and is being updated to the sender’s value (requires --group and the authority to set the group).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;u&lt;/td&gt;
&lt;td&gt;Slot is reserved for future use.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a&lt;/td&gt;
&lt;td&gt;Means that the ACL information changed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;x&lt;/td&gt;
&lt;td&gt;Means that the extended attribute information changed.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;p&gt;Let's see an example using a file inside our already known &lt;em&gt;Users&lt;/em&gt; and &lt;em&gt;Sync&lt;/em&gt; folders:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: I will run this with the &lt;strong&gt;-n&lt;/strong&gt; flag which is he short for &lt;strong&gt;--dry-run&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync -vhrin Users/ Sync
sending incremental file list
&amp;gt;f+++++++++ file1.txt

sent 69 bytes  received 19 bytes  176.00 bytes/sec
total size is 12  speedup is 0.14 (DRY RUN)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, we get &lt;code&gt;&amp;gt;f+++++++++ file1.txt&lt;/code&gt; that means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&amp;gt;&lt;/strong&gt; : a file is being transferred to the local host (received)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;f&lt;/strong&gt; : file not a directory&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;+++++++++&lt;/strong&gt; : no other attributes (because we don't have anything in our &lt;em&gt;Sync&lt;/em&gt; directory)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If I sync our folders and after doing it, I modify the file and sync it again, I get:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;f.sT...... file1.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I got an &lt;strong&gt;s&lt;/strong&gt; meaning that the file size changed and I also got a &lt;strong&gt;T&lt;/strong&gt; instead of the &lt;strong&gt;t&lt;/strong&gt; attribute. The T means that the modification time will be set to the transfer time.&lt;/p&gt;

&lt;p&gt;If I change the owner and the group to root, and run my &lt;strong&gt;rsync&lt;/strong&gt; as super-user, I would get:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;gt;f.st.og... file1.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Verifying Owner and Group of the file so you can see the reuslt above&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ sudo chown root ~/Users/file1.txt &amp;amp;&amp;amp; sudo chgrp root ~/Users/file1.txt &amp;amp;&amp;amp; sudo rsync -vhaio /home/iamgroot/Users/ /home/iamgroot/Sync
sending incremental file list
.d..t...... ./
&amp;gt;f.st.og... file1.txt

sent 186 bytes  received 38 bytes  448.00 bytes/sec
total size is 58  speedup is 0.26
iamgroot@laptop:~$ ls -la Sync/file1.txt
-rw-rw-r-- 1 root root 58 jul 26 01:20 Sync/file1.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will end up this post, mentioning that is very useful to use the &lt;strong&gt;--out-format='arguments'&lt;/strong&gt; with this, just for reference I will show you an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync -vhrin --out-format='%l %n %i' /home/iamgroot/Users/ /home/iamgroot/Sync
sending incremental file list
58 file1.txt &amp;gt;f+++++++++

sent 67 bytes  received 19 bytes  172.00 bytes/sec
total size is 58  speedup is 0.67 (DRY RUN)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final output is &lt;code&gt;58&lt;/code&gt; which is the length in bytes and the argument is the &lt;strong&gt;%l&lt;/strong&gt;. We asked for the file name (&lt;code&gt;file1.txt&lt;/code&gt;) using the &lt;strong&gt;%n&lt;/strong&gt; argument and the &lt;strong&gt;%i&lt;/strong&gt; to get the changes &lt;code&gt;&amp;gt;f+++++++++&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I think you get the idea, if not or if you have any doubt don't hesitate asking me, will be more than happy to help.&lt;/p&gt;

&lt;p&gt;Ok, that'll be it for today.&lt;/p&gt;




&lt;p&gt;Thanks for reading, keep it safe!!&lt;/p&gt;

&lt;p&gt;Follow, ❤️ or 🦄&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>tutorial</category>
      <category>rsync</category>
    </item>
    <item>
      <title>rsync - 10 examples in 11 days (Day 09)</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Sat, 25 Jul 2020 06:34:01 +0000</pubDate>
      <link>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-09-1kgd</link>
      <guid>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-09-1kgd</guid>
      <description>&lt;h1&gt;
  
  
  Day 09
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;10 examples in 11 days&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Sync Local to Remote over SSH and Limit Bandwith
&lt;/h2&gt;

&lt;p&gt;Today is going to be a simple but useful example. I will explain how to limit the bandwidth.&lt;/p&gt;

&lt;p&gt;Let me set a very common scenario. Sometimes we need to upload a very large file or multiple files to a remote instance. We know that this task may take a long time to transfer up to our remote instance, this is ok if we are the only one who is using the internet or if we don't care having &lt;strong&gt;rsync&lt;/strong&gt; consuming all of our bandwidth. But if we are in a shared internet connection or with a limited bandwidth, we don't want to cause a downtime to our connectivity.&lt;/p&gt;

&lt;p&gt;The solution is to limit the bandwitdh, this way &lt;strong&gt;rsync&lt;/strong&gt; can transfer everything correctly and we can still work in something else without loosing connectivity performance.&lt;/p&gt;

&lt;p&gt;The option to do this is &lt;code&gt;--bwlimit=KBPS&lt;/code&gt;. KBPS stands for KiloBytes Per Second. Let's check what the man page says about this option:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;--bwlimit=RATE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This option allows you to specify the maximum transfer rate for the data sent over the socket, specified in units per second. The RATE value can be suffixed with a string to indicate a size&lt;br&gt;
multiplier, and may be a fractional value (e.g. "--bwlimit=1.5m"). If no suffix is specified, the value will be assumed to be in units of 1024 bytes (as if "K" or "KiB" had been appended).&lt;br&gt;
See the --max-size option for a description of all the available suffixes. A value of zero specifies no limit.&lt;/p&gt;

&lt;p&gt;For backward-compatibility reasons, the rate limit will be rounded to the nearest KiB unit, so no rate smaller than 1024 bytes per second is possible.&lt;/p&gt;

&lt;p&gt;Rsync writes data over the socket in blocks, and this option both limits the size of the blocks that rsync writes, and tries to keep the average transfer rate at the requested limit. Some&lt;br&gt;
"burstiness" may be seen where rsync writes out a block of data and then sleeps to bring the average rate into compliance.&lt;/p&gt;

&lt;p&gt;Due to the internal buffering of data, the --progress option may not be an accurate reflection on how fast the data is being sent. This is because some files can show up as being rapidly sent&lt;br&gt;
when the data is quickly buffered, while other can show up as very slow when the flushing of the output buffer occurs. This may be fixed in a future version.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;em&gt;man page&lt;/em&gt; is very explicit on how we can limit the bandwidth of our &lt;strong&gt;rsync&lt;/strong&gt; process.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'll do?
&lt;/h2&gt;

&lt;p&gt;I will backup a file that is 5,3MB in size, and will limit the bandwith to 400Kbps. These means it will take up to 10 or 12 seconds to upload my file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync --progress --bwlimit=400 -vhre ssh /home/iamgroot/backup-to-upload/backup_iamgroot.tar.gz iamgroot@222.222.222.222:backups/
sending incremental file list
backup_iamgroot.tar.gz
          5.30M 100%  407.18kB/s    0:00:12 (xfr#1, to-chk=0/1)

sent 5.30M bytes  received 35 bytes  321.43K bytes/sec
total size is 5.30M  speedup is 1.00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here is an animated gif of &lt;strong&gt;rsync&lt;/strong&gt; while transfering:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7URb9jO7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/csp6it85u4oxfk7utern.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7URb9jO7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/csp6it85u4oxfk7utern.gif" alt="Uploading Remote File with Lited Bandwith" width="567" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything was completely uploaded, let me show you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@remote-instance:~$ ls -l --b=KB  backups/backup_iamgroot.tar.gz | cut -d " " -f5
5303kB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simple right?.&lt;/p&gt;

&lt;p&gt;Well that's it for today's example, hope you enjoyed reading.&lt;/p&gt;




&lt;p&gt;Thanks for reading, keep it safe!!&lt;/p&gt;

&lt;p&gt;Follow, ❤ or 🦄&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>rsync</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>rsync - 10 examples in 11 days (Day 08)</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Thu, 23 Jul 2020 18:40:17 +0000</pubDate>
      <link>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-08-29k8</link>
      <guid>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-08-29k8</guid>
      <description>&lt;h1&gt;
  
  
  Day 08
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;10 examples in 11 days&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Sync Remote to Local over SSH
&lt;/h2&gt;

&lt;p&gt;Yesterday on &lt;a href="https://dev.to/jmr_code_social/rsync-10-examples-in-11-days-day-07-1g2m"&gt;Day 07&lt;/a&gt; I showed how we can sync files from our local machine to our remote machine using &lt;strong&gt;ssh&lt;/strong&gt;. Today is the other way around. I will request a file from remote to local.&lt;/p&gt;

&lt;p&gt;The syntax it's almost the same one from yesterday, the difference between yesterday's and the the one I am using today is that with the one below, I will not remove my remote file and the yesterday's source will be our destination and our destination will be yesterday's source. Let's remember the syntax and let me describe it to you so you can see by your self what I am talking about:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: As yesterday I will not show the local nor remote machines IP. Instead I will always display 111.111.111.111 IP as remote and 222.222.222.222 as local&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync (1)--progress (2)-vhre (3)ssh (4)iamgroot@111.111.111.111:(5)[remote folder]/(6)[remote file] (7)[local folder to download]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see what the above syntax does:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;--progress&lt;/strong&gt;: shows progress while synching&lt;/li&gt;
&lt;li&gt;I used &lt;strong&gt;-vhre&lt;/strong&gt; options&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;-v&lt;/strong&gt;: verbose&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-h&lt;/strong&gt;: human readable&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-r&lt;/strong&gt;: recursive&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-e&lt;/strong&gt;: allows us to use ssh as remote shell and execute its commands&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ssh&lt;/strong&gt;: invoking the &lt;em&gt;ssh&lt;/em&gt; service to be used as remote shell.&lt;/li&gt;
&lt;li&gt;ssh connection parameters&lt;/li&gt;
&lt;li&gt;remote folder with full path&lt;/li&gt;
&lt;li&gt;remote file to download&lt;/li&gt;
&lt;li&gt;local folder where the remote file will be downloaded&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If the local folder doesn't exist it will be created&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I created a folder called &lt;em&gt;download-folder&lt;/em&gt; in my remote instance and inside of it I created a file called &lt;em&gt;file_download.txt&lt;/em&gt;. I will download this file into my ~/Sync folder that we have been using.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@remote-instance:~$ mkdir download-folder &amp;amp;&amp;amp; touch download-folder/file_download.txt &amp;amp;&amp;amp; echo "Hello World I will be downloaded" &amp;gt;&amp;gt; download-folder/file_download.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's sync from remote to local&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync --progress -vhre ssh iamgroot@111.111.111.111:download-folder/file_download.txt ~/Sync
receiving incremental file list
file_download.txt
             12 100%   11.72kB/s    0:00:00 (xfr#1, to-chk=0/1)

sent 43 bytes  received 113 bytes  34.67 bytes/sec
total size is 12  speedup is 0.08
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's check if it got downloaded&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ ls Sync/
file1.txt  file2.txt  file3.txt  file_download.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nice right?&lt;/p&gt;

&lt;p&gt;As you can see so far, &lt;strong&gt;rsync&lt;/strong&gt; is a great tool to keep your files sync locally and remotely.&lt;/p&gt;

&lt;p&gt;We are almost ending this series, hope you all readers are enjoying it, let me know if you have any doubt and I will be more than happy to help.&lt;/p&gt;




&lt;p&gt;Thanks for reading, keep it safe!!&lt;/p&gt;

&lt;p&gt;Follow, ❤ or 🦄&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>rsync</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>rsync - 10 examples in 11 days (Day 07)</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Thu, 23 Jul 2020 07:23:28 +0000</pubDate>
      <link>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-07-1g2m</link>
      <guid>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-07-1g2m</guid>
      <description>&lt;h1&gt;
  
  
  Day 07
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;10 examples in 11 days&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Sync Local to Remote over SSH
&lt;/h2&gt;

&lt;p&gt;Today I will talk about how we can sync files from our local machine to our remote machine using &lt;strong&gt;ssh&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I have a remote machine where I will be connecting to. I use ssh with a public and private key to connect to it and this way I will not have to be asked for a password.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: I will not show the local nor remote machines IP. Instead I will always display 111.111.111.111 IP as remote and 222.222.222.222 as local&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I have a folder called &lt;em&gt;~/backup-to-upload/&lt;/em&gt;. Inside of this folder I store the latest backup file as a &lt;em&gt;.tar.gz&lt;/em&gt;. This file will be sitting there waiting for me to &lt;strong&gt;rsync&lt;/strong&gt; it into my remote machine. Once I have upload the &lt;em&gt;tar&lt;/em&gt; backup, it gets deleted leaving the &lt;em&gt;~/backup-to-upload/&lt;/em&gt; folder empty.&lt;/p&gt;

&lt;p&gt;Let's see the syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync (1)--progress (2)--remove-source-files (3)-vhre (4)ssh (5)[backup file to upload] (6)iamgroot@111.111.111.111:(7)[remote backup folder]/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see what the above syntax does:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;--progress&lt;/strong&gt;: shows progress while synching&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;--remove-source-files&lt;/strong&gt;: after transfer it will remove source file&lt;/li&gt;
&lt;li&gt;I used &lt;strong&gt;-vhre&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;-v&lt;/strong&gt;: verbose&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-h&lt;/strong&gt;: human readable&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-r&lt;/strong&gt;: recursive&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-e&lt;/strong&gt;: allows us to use ssh as remote shell and execute its commands&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ssh&lt;/strong&gt;: invoking the &lt;em&gt;ssh&lt;/em&gt; service to be used as remote shell.&lt;/li&gt;
&lt;li&gt;backup file to upload with full path&lt;/li&gt;
&lt;li&gt;ssh connection&lt;/li&gt;
&lt;li&gt;remote folder&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If the remote folder doesn't exist it will be created&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's see what I have at my remote machine before we run the rsync command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@remote-instance:~$ ls
scripts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's upload our tar file to the remote machine&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync --progress --remove-source-files -vhre ssh /home/iamgroot/backup-to-upload/backup.tar.gz  iamgroot@111.111.111.111:backups/
sending incremental file list
backup.tar.gz
            195 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/1)

sent 295 bytes  received 43 bytes  75.11 bytes/sec
total size is 195  speedup is 0.58
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checking if the tar backup file got removed from source&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ ls -a backup-to-upload/
.  ..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Empty!!!&lt;/p&gt;

&lt;p&gt;Now let's check on the remote machine and first I will check if the folder backups was created and then if it has our backup.tar.gz&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ ssh iamgroot@111.111.111.111
Last login: Thu Jul 23 00:38:46 2020 from 222.222.222.222
iamgroot@remote-instance:~$ ls
backups  scripts
iamgroot@remote-instance:~$ ls -a backups/
.  ..  backup.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, it not just created the backups folder, it uploaded our tar file.&lt;/p&gt;

&lt;p&gt;Awesome, another example accomplished!&lt;/p&gt;




&lt;p&gt;Ok, that'll be for today's example, thanks for reading, ping me if you need any help!!!&lt;/p&gt;

&lt;p&gt;Follow, ❤ or 🦄&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>rsync</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>rsync - 10 examples in 11 days (Day 06)</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Tue, 21 Jul 2020 23:52:40 +0000</pubDate>
      <link>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-06-454o</link>
      <guid>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-06-454o</guid>
      <description>&lt;h1&gt;
  
  
  Day 06
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;10 examples in 11 days&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Add Linux User + Unix date stamp to backup folder
&lt;/h2&gt;

&lt;p&gt;Today's article is a short article I will not talk about an option of &lt;strong&gt;rsync&lt;/strong&gt;, is just a useful syntax that we can attach to the backup destination folder.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/jmr_code_social/rsync-10-examples-in-11-days-day-04-1mkd"&gt;Day 04&lt;/a&gt; I talked about backups and what I will mention today comes very handy when doing backups while synching.&lt;/p&gt;

&lt;h3&gt;
  
  
  So, Adding a USER + UNIX TIMESTAMP?
&lt;/h3&gt;

&lt;p&gt;Yes, as you read, adding a linux user can be useful to know who did it and adding a timestamp let's us know when.&lt;/p&gt;

&lt;p&gt;Let me show with an example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Let's see what my &lt;em&gt;Source&lt;/em&gt;, &lt;em&gt;Destination&lt;/em&gt; and &lt;em&gt;Backup&lt;/em&gt; directories have
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ ls -F ~/Users
file1.txt  file2.txt  file3.txt
iamgroot@laptop:~$ ls -F ~/Sync
iamgroot@laptop:~$ ls -F ~/backups
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Source &lt;em&gt;~/Users&lt;/em&gt; has file1.txt, file2.txt and file3.txt&lt;/li&gt;
&lt;li&gt;Destination &lt;em&gt;~/Sync&lt;/em&gt; is empty&lt;/li&gt;
&lt;li&gt;Backups &lt;em&gt;~/backups&lt;/em&gt; is empty&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's now add the current linux User (\$USER) separated by a dash unix timestamp to the backup folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync -vhrb --backup-dir='/home/iamgroot/backups/'$(date +$USER-%s) --suffix='.bak' ~/Users/ ~/Sync
sending incremental file list
file1.txt
file2.txt
file3.txt

sent 276 bytes  received 73 bytes  698.00 bytes/sec
total size is 36  speedup is 0.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's check each folder again&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$  ls -F ~/Users &amp;amp;&amp;amp; printf -- '-%.0s' {1..10}; echo "" &amp;amp;&amp;amp; ls -F ~/Sync &amp;amp;&amp;amp; printf -- '-%.0s' {1..10}; echo "" &amp;amp;&amp;amp; ls -F ~/backups/ &amp;amp;&amp;amp; ls -F ~/backups/iamgroot-1595372929/
file1.txt  file2.txt  file3.txt
----------
file1.txt  file2.txt  file3.txt
----------
iamgroot-1595372929/
file1.txt.bak  file2.txt.bak  file3.txt.bak
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Obviously you can add &lt;code&gt;$(date +$USER-%s)&lt;/code&gt; as suffix or using how ever you want.&lt;/p&gt;

&lt;p&gt;Cool!!!. Now you know a different way to perform a single task&lt;/p&gt;




&lt;p&gt;Ok, that'll be for today's example, thanks for reading!!!&lt;/p&gt;

&lt;p&gt;Follow, ❤ or 🦄&lt;/p&gt;

</description>
      <category>linux</category>
      <category>rsync</category>
      <category>bash</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>rsync - 10 examples in 11 days (Day 05)</title>
      <dc:creator>m4r4v</dc:creator>
      <pubDate>Tue, 21 Jul 2020 02:23:42 +0000</pubDate>
      <link>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-05-2foe</link>
      <guid>https://dev.to/m4r4v/rsync-10-examples-in-11-days-day-05-2foe</guid>
      <description>&lt;h1&gt;
  
  
  Day 05
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;10 examples in 11 days&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Delete
&lt;/h2&gt;

&lt;p&gt;Today is the turn of the &lt;strong&gt;--delete&lt;/strong&gt; option. I use this option a lot, when it comes to backups or to mantain source and destination files up to date.&lt;/p&gt;

&lt;p&gt;Eventually you sync too much files and sometimes you just delete some files at source without removing them in destination. You know &lt;strong&gt;rsync&lt;/strong&gt; does not remove any file at destination no matter if they do not exist at source, it just sync files/directories using blocks on files/directories that exist on both sides.&lt;/p&gt;

&lt;p&gt;This is when &lt;strong&gt;--delete&lt;/strong&gt; come handy. If you remove a file/s on soure and if you use this option, it will remove those files that doesn't exist in source at destination.&lt;/p&gt;

&lt;p&gt;In our last article about &lt;a href="https://dev.to/jmr_code_social/rsync-10-examples-in-11-days-day-04-1mkd"&gt;backups&lt;/a&gt; I used &lt;em&gt;~/Users&lt;/em&gt; folder as source on which I had a file called &lt;em&gt;file1.txt&lt;/em&gt; and we used it to sync and backup to our destination &lt;em&gt;~/Sync&lt;/em&gt; folder. I will create another file and will call it &lt;em&gt;file2.txt&lt;/em&gt; and remove our &lt;em&gt;file1.txt&lt;/em&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rm ~/Users/file1.txt &amp;amp;&amp;amp; touch ~/Users/file2.txt &amp;amp;&amp;amp; echo "Hello World" &amp;gt;&amp;gt; ~/Users/file2.txt &amp;amp;&amp;amp; ls -F ~/Users/
file2.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, I will sync our source and destinations folders and check what we have in both folders&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ ls -F ~/Users &amp;amp;&amp;amp; ls -F ~/Sync
file2.txt
file1.txt  file2.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, in our source folder we only have &lt;em&gt;file2.txt&lt;/em&gt; and in our destination we still have &lt;em&gt;file1.txt&lt;/em&gt;. Here is when we should use the &lt;strong&gt;--delete&lt;/strong&gt; option. Using it, will remove files in destination missing at source&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync -vhr --delete ~/Users/ ~/Sync &amp;amp;&amp;amp; ls -F ~/Users &amp;amp;&amp;amp; ls -F ~/Sync
sending incremental file list
deleting file1.txt
file2.txt

sent 124 bytes  received 48 bytes  344.00 bytes/sec
total size is 12  speedup is 0.07
file2.txt
file2.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we only have &lt;em&gt;file2.txt&lt;/em&gt; in both folders. Nice!!&lt;/p&gt;

&lt;p&gt;I do have to point out something. We do have few more options to play with:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;--delete-before&lt;/td&gt;
&lt;td&gt;receiver deletes before transfer, not during (this is the default)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--delete-during&lt;/td&gt;
&lt;td&gt;receiver deletes during the transfer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--delete-delay&lt;/td&gt;
&lt;td&gt;find deletions during, delete after&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--delete-after&lt;/td&gt;
&lt;td&gt;receiver deletes after transfer, not during&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--delete-excluded&lt;/td&gt;
&lt;td&gt;also delete excluded files from dest dirs&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Another great option that we must include in this article is the &lt;strong&gt;--remove-source-files&lt;/strong&gt; which removes from source synchronized files. Be aware that this &lt;em&gt;option&lt;/em&gt; don't remove directories. This &lt;em&gt;option&lt;/em&gt; is very useful when doing backups (tar, zip files), since backups are usually compressed files we barely want to keep those files at source after synching. Let's try it out, I will create a folder called ~/Users/backup, then I will create some files inside ~/Users/backup/ and at the end I will back them up using tar. After all this I will perform a sync and will check if it gets removed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ mkdir ~/Users/backup &amp;amp;&amp;amp; touch ~/Users/backup/tobackup{1..5}.txt &amp;amp;&amp;amp; tar -cvzf ~/Users/backup.tar.gz ~/Users/backup/ &amp;amp;&amp;amp; ls -F ~/Users
tar: Removing leading `/' from member names
/home/iamgroot/Users/backup/
/home/iamgroot/Users/backup/tobackup3.txt
/home/iamgroot/Users/backup/tobackup4.txt
/home/iamgroot/Users/backup/tobackup5.txt
/home/iamgroot/Users/backup/tobackup2.txt
/home/iamgroot/Users/backup/tobackup1.txt
backup/  backup.tar.gz  file2.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Performing &lt;strong&gt;rsync&lt;/strong&gt; with &lt;em&gt;--remove-source-files&lt;/em&gt; option&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iamgroot@laptop:~$ rsync -vhr --remove-source-files ~/Users/backup.tar.gz ~/Sync &amp;amp;&amp;amp; ls -F ~/Users
sending incremental file list
backup.tar.gz

sent 292 bytes  received 43 bytes  670.00 bytes/sec
total size is 196  speedup is 0.59
backup/  file2.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Ok, that'll be for today's example, thanks for reading!!!&lt;/p&gt;

&lt;p&gt;Follow, ❤ or 🦄&lt;/p&gt;

</description>
      <category>linux</category>
      <category>rsync</category>
      <category>bash</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
