<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Google Cloud Storage &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/google-cloud-storage/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Tue, 03 Oct 2023 14:29:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>Google Cloud Storage &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>Rclone: Backing Up Synology NAS to GCP</title>
		<link>https://myshittycode.com/2023/10/03/rclone-backing-up-synology-nas-to-gcp/</link>
					<comments>https://myshittycode.com/2023/10/03/rclone-backing-up-synology-nas-to-gcp/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Tue, 03 Oct 2023 14:29:13 +0000</pubDate>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Google Cloud Platform]]></category>
		<category><![CDATA[Google Cloud Storage]]></category>
		<category><![CDATA[Rclone]]></category>
		<category><![CDATA[Synology NAS]]></category>
		<guid isPermaLink="false">https://myshittycode.com/?p=2396</guid>

					<description><![CDATA[<p>This post shows how you can use Rclone to back up your data from a Synology NAS to a storage bucket in GCP. Why Backing Up Synology NAS Backing up data is like wearing a seat belt when driving, where nothing bad happens 99% of the time. However, when the 1% strikes unexpectedly one day, [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2023/10/03/rclone-backing-up-synology-nas-to-gcp/">Rclone: Backing Up Synology NAS to GCP</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#why-backing-up-synology-nas">Why Backing Up Synology NAS</a></li><li><a href="#why-rclone">Why Rclone</a></li><li><a href="#why-gcp">Why GCP</a></li><li><a href="#configuration">Configuration</a><ul><li><a href="#setting-up-gcp-resources">Setting up GCP Resources</a></li><li><a href="#setting-up-rclone-in-synology-nas">Setting Up Rclone in Synology NAS</a><ul><li><a href="#ways-to-install-rclone">Ways to Install Rclone</a></li><li><a href="#whats-in-docker-appdata-rclone">What&#8217;s in /docker/appdata/rclone</a></li><li><a href="#downloading-docker-image">Downloading Docker Image</a></li><li><a href="#creating-docker-container-with-dry-run">Creating Docker Container (with &#8211;dry-run)</a></li><li><a href="#creating-docker-container-without-dry-run">Creating Docker Container (without &#8211;dry-run)</a></li><li><a href="#scheduling-docker-container-to-run">Scheduling Docker Container to Run</a></li></ul></li></ul></li></ul></nav></div>



<p>This post shows how you can use Rclone to back up your data from a Synology NAS to a storage bucket in GCP.</p>



<h2 class="wp-block-heading" id="why-backing-up-synology-nas">Why Backing Up Synology NAS</h2>



<p>Backing up data is like wearing a seat belt when driving, where nothing bad happens 99% of the time. However, when the 1% strikes unexpectedly one day, the &#8220;future&#8221; you will be grateful that you do not lose any precious data, such as childhood photos, important documents, etc. </p>



<p>When you own several machines at home, it makes sense to centralize the shared data in a local NAS, such as Synology NAS. You may also configure Time Machine to seamlessly back up each Mac to Synology NAS every weekend. It is equally important to back up the data in Synology NAS to the cloud. Your car&#8217;s seat belt might be faulty, but you still have an airbag. If a thief breaks into your house, steals your shiny NAS, and burns your house down, you still have your data in the cloud. </p>



<p>The moral of the story is always to back up your data, preferably using the <a href="https://www.cisa.gov/sites/default/files/publications/data_backup_options.pdf" target="_blank" rel="noopener">3-2-1 rule</a>.</p>



<h2 class="wp-block-heading" id="why-rclone">Why Rclone</h2>



<p>The most confusing part of the Synology NAS backup process is there are several ways to do this. The three popular solutions are <a href="https://www.synology.com/en-global/dsm/feature/cloud_sync" target="_blank" rel="noopener">Cloud Sync</a>, <a href="https://www.synology.com/en-global/dsm/feature/hyper_backup" target="_blank" rel="noopener">Hyper Backup</a>, and <a href="https://rclone.org/" target="_blank" rel="noopener">Rclone</a>. Each solution allows us to push data to various cloud providers. This <a href="https://www.reddit.com/r/synology/comments/hsy29y/hyper_backup_vs_cloud_sync_vs_rclone/" target="_blank" rel="noopener">Reddit post</a> nicely sums it all up. If I can summarize the most significant disadvantage of each solution in a few words, it will be:</p>



<ul class="wp-block-list">
<li>Cloud Sync silently ignores file names with unsupported characters.</li>



<li>Hyper Backup landlocks you to Synology solution because you can&#8217;t browse the backed-up files in the cloud.</li>



<li>Rclone doesn&#8217;t have a pretty GUI.</li>
</ul>



<p>Rclone seems more palatable among these solutions because I know all my data will be backed up. When disaster strikes next time, I also don&#8217;t have to deal with the proprietary format during my data recovery process. Who knows if Synology will still be around 20 years from now?</p>



<h2 class="wp-block-heading" id="why-gcp">Why GCP</h2>



<p>In the past, I configured my Synology NAS to perform a seamless backup to <a href="https://www.crashplan.com/en-us/" target="_blank" rel="noopener">CrashPlan</a> using <a href="https://hub.docker.com/r/jlesage/crashplan-pro" target="_blank" rel="noopener">this Docker solution</a>. It has worked flawlessly for many years. The main reasons I want to move the backups to my personal GCP org are:</p>



<ul class="wp-block-list">
<li>I have free GCP credits. Even without the GCP credits, based on <a href="https://cloud.google.com/products/calculator" target="_blank" rel="noopener">the GCP Pricing Calculator</a>, it is still cheaper to back up my data to a regional <a href="https://cloud.google.com/storage/docs/storage-classes#classes" target="_blank" rel="noopener">Archive storage</a> bucket than CrashPlan.</li>



<li>I can customize the number of backup versions and retention policies.</li>



<li>It is faster to recover all my data if needed.</li>



<li>I want to secure the data and GCP resources myself.</li>
</ul>



<p>You can swap out GCP with a cloud provider of your choice. For example, you can use Rclone to back up all your photos to <a href="https://www.amazon.com/b/?node=15547130011" target="_blank" rel="noopener">Amazon Photos</a> for free if you have a Prime membership and your <a href="https://www.amazon.com/gp/help/customer/display.html?nodeId=GGU2SU8Y22DZYRMQ" target="_blank" rel="noopener">photo formats are supported</a>. My RAW images (supported) also have corresponding XMP files (not supported), and I want to back up other file formats too.</p>



<h2 class="wp-block-heading" id="configuration">Configuration</h2>



<p>This diagram below helps you to visualize the solution.</p>



<figure class="wp-block-image aligncenter size-large"><img fetchpriority="high" decoding="async" width="1024" height="514" src="https://myshittycode.com/wp-content/uploads/2023/08/synology-to-gcp-1-1024x514.png?x45560" alt="Synology NAS" class="wp-image-2418" srcset="https://myshittycode.com/wp-content/uploads/2023/08/synology-to-gcp-1-1024x514.png 1024w, https://myshittycode.com/wp-content/uploads/2023/08/synology-to-gcp-1-300x151.png 300w, https://myshittycode.com/wp-content/uploads/2023/08/synology-to-gcp-1-768x386.png 768w, https://myshittycode.com/wp-content/uploads/2023/08/synology-to-gcp-1.png 1312w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading" id="setting-up-gcp-resources">Setting up GCP Resources</h3>



<p>The best way to secure the data backups is to create a separate GCP project where only a specific service account has sufficient permission to write to a storage bucket. At a high level:</p>



<ul class="wp-block-list">
<li>Create a GCP project.</li>



<li>Create a storage bucket.
<ul class="wp-block-list">
<li>Enable object versioning and limit them to N versions (to prevent rising storage costs).</li>
</ul>
</li>



<li>Create a service account.</li>



<li>Grant service account with Storage Object Admin (roles/storage.objectAdmin) at the project level.</li>



<li>Create a service account key.</li>



<li>Download the service account key file in JSON format to the local machine first. In this post, this file is named <strong>service-account.json</strong>.</li>



<li><strong>BONUS</strong>: If you are paranoid, <a href="https://myshittycode.com/2023/08/18/vpc-sc-2-ways-to-fix-no_matching_access_level-error/" data-type="post" data-id="2359">configure a VPC Service Control perimeter and put that project within the perimeter</a>. This ensures only the whitelisted IPs can access these project resources. This way, even if the service account key is compromised, adversaries cannot access the protected resources unless they also spoof the IPs.</li>
</ul>



<h3 class="wp-block-heading" id="setting-up-rclone-in-synology-nas">Setting Up Rclone in Synology NAS</h3>



<h4 class="wp-block-heading" id="ways-to-install-rclone">Ways to Install Rclone</h4>



<p>There are multiple ways to install Rclone in Synology NAS:</p>



<ul class="wp-block-list">
<li><a href="https://rclone.org/install/" target="_blank" rel="noopener">Install Rclone</a> directly in Synology NAS.</li>



<li>Install Rclone using Docker (<a href="https://hub.docker.com/r/rclone/rclone" target="_blank" rel="noopener">rclone/rclone</a>).</li>



<li>Install Rclone with GUI using Docker (<a href="https://hub.docker.com/r/romancin/rclonebrowser" target="_blank" rel="noopener">romancin/rclonebrowser</a>).</li>
</ul>



<p>In this post, I use the second solution (without GUI) because simpler implementation means less chance of the tool breaking in the future. Besides, this is a &#8220;set-and-forget&#8221; process, and I don&#8217;t need to use the GUI most of the time.</p>



<h4 class="wp-block-heading" id="whats-in-docker-appdata-rclone">What&#8217;s in /docker/appdata/rclone</h4>



<p>/docker/appdata should already exist when the Docker package is installed in Synology NAS. You only need to create a child folder named <strong>rclone</strong> (or any name you like). This folder contains three files:</p>



<ul class="wp-block-list">
<li><strong>excludes.txt</strong> = File patterns to be excluded from the backup process.</li>



<li><strong>rclone.conf</strong> = Rclone configuration.</li>



<li><strong>service-account.json</strong> = The service account key file that you downloaded to your local machine from GCP.</li>
</ul>



<p>Here&#8217;s my example of <strong>excludes.txt</strong>, and customize it to your needs:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
@eaDir/**
.**
</pre></div>


<p><strong>rclone.conf</strong> can be generated using <strong>rclone config</strong> command. However, that must be done outside Synology NAS (i.e., on your local machine). That said, most of this command&#8217;s interactive steps are unnecessary since you created the storage bucket earlier. All you need is exactly this and nothing else:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#x5B;gcp]
type = google cloud storage
service_account_file = /config/rclone/service-account.json
</pre></div>


<h4 class="wp-block-heading" id="downloading-docker-image">Downloading Docker Image</h4>



<p>Go to <strong>DSM</strong> &gt; <strong>Docker</strong> to download rclone/rclone image. </p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="586" src="https://myshittycode.com/wp-content/uploads/2023/10/1-download-image-1024x586.png?x45560" alt="" class="wp-image-2504" srcset="https://myshittycode.com/wp-content/uploads/2023/10/1-download-image-1024x586.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/1-download-image-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/1-download-image-768x440.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/1-download-image-1536x880.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/1-download-image.png 1966w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading" id="creating-docker-container-with-dry-run">Creating Docker Container (with &#8211;dry-run)</h4>



<p>This step ensures the Rclone is configured properly before any files are copied to the storage bucket to prevent incurring unnecessary costs.</p>



<p>First, create a new container.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="584" src="https://myshittycode.com/wp-content/uploads/2023/10/2-container-create-1024x584.png?x45560" alt="" class="wp-image-2505" srcset="https://myshittycode.com/wp-content/uploads/2023/10/2-container-create-1024x584.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/2-container-create-300x171.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/2-container-create-768x438.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/2-container-create-1536x876.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/2-container-create.png 1968w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Use rclone/rclone image.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="588" src="https://myshittycode.com/wp-content/uploads/2023/10/3-container-image-1024x588.png?x45560" alt="" class="wp-image-2506" srcset="https://myshittycode.com/wp-content/uploads/2023/10/3-container-image-1024x588.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/3-container-image-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/3-container-image-768x441.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/3-container-image-1536x881.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/3-container-image.png 1966w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>No changes to the network settings.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="589" src="https://myshittycode.com/wp-content/uploads/2023/10/4-container-network-1024x589.png?x45560" alt="" class="wp-image-2507" srcset="https://myshittycode.com/wp-content/uploads/2023/10/4-container-network-1024x589.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/4-container-network-300x173.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/4-container-network-768x442.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/4-container-network-1536x884.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/4-container-network.png 1968w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Enter the container name, and go to <strong>Advanced Settings</strong>.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="589" src="https://myshittycode.com/wp-content/uploads/2023/10/5-container-general-settings-1024x589.png?x45560" alt="" class="wp-image-2508" srcset="https://myshittycode.com/wp-content/uploads/2023/10/5-container-general-settings-1024x589.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/5-container-general-settings-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/5-container-general-settings-768x441.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/5-container-general-settings-1536x883.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/5-container-general-settings.png 1966w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Under <strong>Execution Command</strong>, enter the following command:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sync /data gcp:&#x5B;BUCKET_NAME] --exclude-from /config/rclone/excludes.txt --gcs-bucket-policy-only --verbose --dry-run
</pre></div>


<p>Replace <strong>[BUCKET_NAME]</strong> with your own bucket name.</p>



<p><strong>IMPORTANT:</strong> Synology does not allow us to edit the execution command after creating a container!</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="584" src="https://myshittycode.com/wp-content/uploads/2023/10/6-container-advanced-settings-1-1024x584.png?x45560" alt="" class="wp-image-2531" srcset="https://myshittycode.com/wp-content/uploads/2023/10/6-container-advanced-settings-1-1024x584.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/6-container-advanced-settings-1-300x171.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/6-container-advanced-settings-1-768x438.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/6-container-advanced-settings-1-1536x876.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/6-container-advanced-settings-1.png 1970w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>No changes to the port settings.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="588" src="https://myshittycode.com/wp-content/uploads/2023/10/7-container-port-settings-1024x588.png?x45560" alt="" class="wp-image-2510" srcset="https://myshittycode.com/wp-content/uploads/2023/10/7-container-port-settings-1024x588.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/7-container-port-settings-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/7-container-port-settings-768x441.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/7-container-port-settings-1536x882.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/7-container-port-settings.png 1964w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Define the volume mounts:</p>



<ul class="wp-block-list">
<li>/config/rclone = contains the Rclone configuration files.</li>



<li>/data = contains data to be backed up.
<ul class="wp-block-list">
<li>Because you can&#8217;t perform a volume mount on root /, each root folder needs to be volume-mounted to a subfolder within /data that you wish to back up.</li>
</ul>
</li>
</ul>



<p><strong>TIP:</strong> Consider mounting a data folder with the least amount of data when doing the dry run test. You can add/remove folders on an existing container later.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="587" src="https://myshittycode.com/wp-content/uploads/2023/10/8-container-volume-settings-1024x587.png?x45560" alt="" class="wp-image-2511" srcset="https://myshittycode.com/wp-content/uploads/2023/10/8-container-volume-settings-1024x587.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/8-container-volume-settings-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/8-container-volume-settings-768x440.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/8-container-volume-settings-1536x881.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/8-container-volume-settings.png 1964w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Review the summary.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="588" src="https://myshittycode.com/wp-content/uploads/2023/10/9-container-summary-1024x588.png?x45560" alt="" class="wp-image-2512" srcset="https://myshittycode.com/wp-content/uploads/2023/10/9-container-summary-1024x588.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/9-container-summary-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/9-container-summary-768x441.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/9-container-summary-1536x882.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/9-container-summary.png 1964w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Once the container is created, click on the toggle to run it.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="585" src="https://myshittycode.com/wp-content/uploads/2023/10/10-container-created-1024x585.png?x45560" alt="" class="wp-image-2513" srcset="https://myshittycode.com/wp-content/uploads/2023/10/10-container-created-1024x585.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/10-container-created-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/10-container-created-768x439.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/10-container-created-1536x878.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/10-container-created.png 1966w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Review the container log. You can drop a few files into the mounted folder and rerun the container. The files should show up in the log.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="633" src="https://myshittycode.com/wp-content/uploads/2023/10/11-container-run-log-1024x633.png?x45560" alt="" class="wp-image-2514" srcset="https://myshittycode.com/wp-content/uploads/2023/10/11-container-run-log-1024x633.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/11-container-run-log-300x185.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/11-container-run-log-768x475.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/11-container-run-log-1536x949.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/11-container-run-log.png 1854w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading" id="creating-docker-container-without-dry-run">Creating Docker Container (without &#8211;dry-run)</h4>



<p>Now that you have a working container to perform the dry run test, it&#8217;s time to back up the data to the cloud.</p>



<p>As mentioned earlier, it is not possible to edit the existing container&#8217;s execution command. The existing container contains the <strong>&#8211;dry-run</strong> flag on the execution command. The simplest way is to export the container setting, which will be used to create a new container without the <strong>&#8211;dry-run</strong> flag.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="585" src="https://myshittycode.com/wp-content/uploads/2023/10/12-container-export-1024x585.png?x45560" alt="" class="wp-image-2515" srcset="https://myshittycode.com/wp-content/uploads/2023/10/12-container-export-1024x585.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/12-container-export-300x171.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/12-container-export-768x439.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/12-container-export-1536x877.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/12-container-export.png 1972w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Export just the container settings to a local machine.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="585" src="https://myshittycode.com/wp-content/uploads/2023/10/13-container-export-local-1024x585.png?x45560" alt="" class="wp-image-2516" srcset="https://myshittycode.com/wp-content/uploads/2023/10/13-container-export-local-1024x585.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/13-container-export-local-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/13-container-export-local-768x439.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/13-container-export-local-1536x878.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/13-container-export-local.png 1966w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Open the JSON file, locate and remove <strong>&#8211;dry-run</strong> from <strong>cmd</strong>. Save the file.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; highlight: [4]; title: ; notranslate">
{
   &quot;CapAdd&quot; : &#x5B;],
   &quot;CapDrop&quot; : &#x5B;],
   &quot;cmd&quot; : &quot;sync /data gcp:&#x5B;BUCKET_NAME] --exclude-from /config/rclone/excludes.txt --gcs-bucket-policy-only --verbose --dry-run&quot;,
   &quot;cpu_priority&quot; : 0,
   &quot;enable_publish_all_ports&quot; : false,
   ...
}
</pre></div>


<p>Return to the Docker container window to import this JSON file to create a new container.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="582" src="https://myshittycode.com/wp-content/uploads/2023/10/14-container-import-1024x582.png?x45560" alt="" class="wp-image-2517" srcset="https://myshittycode.com/wp-content/uploads/2023/10/14-container-import-1024x582.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/14-container-import-300x171.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/14-container-import-768x437.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/14-container-import-1536x873.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/14-container-import.png 1966w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Upload the modified JSON file and provide a new container name.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="586" src="https://myshittycode.com/wp-content/uploads/2023/10/15-container-import-local-1024x586.png?x45560" alt="" class="wp-image-2518" srcset="https://myshittycode.com/wp-content/uploads/2023/10/15-container-import-local-1024x586.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/15-container-import-local-300x172.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/15-container-import-local-768x440.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/15-container-import-local-1536x879.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/15-container-import-local.png 1964w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Now, there are 2 Rclone containers: one with the <strong>&#8211;dry-run</strong> flag and another without it. It is up to you whether to retain or delete the container with the <strong>&#8211;dry-run</strong> flag. </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="584" src="https://myshittycode.com/wp-content/uploads/2023/10/16-container-import-successful-1024x584.png?x45560" alt="" class="wp-image-2519" srcset="https://myshittycode.com/wp-content/uploads/2023/10/16-container-import-successful-1024x584.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/16-container-import-successful-300x171.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/16-container-import-successful-768x438.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/16-container-import-successful-1536x876.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/16-container-import-successful.png 1964w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading" id="scheduling-docker-container-to-run">Scheduling Docker Container to Run</h4>



<p>To ensure the Rclone runs to back up the files to the cloud, create a task scheduler. In this example, a triggered task is created so that Rclone can perform the backups on boot-up.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="575" src="https://myshittycode.com/wp-content/uploads/2023/10/17-scheduler-create-1024x575.png?x45560" alt="" class="wp-image-2520" srcset="https://myshittycode.com/wp-content/uploads/2023/10/17-scheduler-create-1024x575.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/17-scheduler-create-300x168.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/17-scheduler-create-768x431.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/17-scheduler-create-1536x862.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/17-scheduler-create.png 2024w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Ensure to run the task as root.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="574" src="https://myshittycode.com/wp-content/uploads/2023/10/18-scheduler-general-1024x574.png?x45560" alt="" class="wp-image-2521" srcset="https://myshittycode.com/wp-content/uploads/2023/10/18-scheduler-general-1024x574.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/18-scheduler-general-300x168.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/18-scheduler-general-768x430.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/18-scheduler-general-1536x860.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/18-scheduler-general.png 2028w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Specify the following script to execute. This script ensures the Docker service is running first before starting the container to perform the backup.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
while (synopkg status Docker | jq -r &#039;.status&#039; | grep -vq &quot;running&quot;); do
  sleep 10
done

docker container start rclone
</pre></div>


<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="575" src="https://myshittycode.com/wp-content/uploads/2023/10/19-scheduler-task-settings-1024x575.png?x45560" alt="" class="wp-image-2522" srcset="https://myshittycode.com/wp-content/uploads/2023/10/19-scheduler-task-settings-1024x575.png 1024w, https://myshittycode.com/wp-content/uploads/2023/10/19-scheduler-task-settings-300x168.png 300w, https://myshittycode.com/wp-content/uploads/2023/10/19-scheduler-task-settings-768x431.png 768w, https://myshittycode.com/wp-content/uploads/2023/10/19-scheduler-task-settings-1536x862.png 1536w, https://myshittycode.com/wp-content/uploads/2023/10/19-scheduler-task-settings.png 2028w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>That&#8217;s it! Every time the Synology NAS boots up, the Rclone container will run to perform any necessary data backup to the cloud.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2023/10/03/rclone-backing-up-synology-nas-to-gcp/">Rclone: Backing Up Synology NAS to GCP</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2023/10/03/rclone-backing-up-synology-nas-to-gcp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2396</post-id>	</item>
		<item>
		<title>GCSFuse + Docker: &#8220;Error while creating mount source path &#8216;/a&#8217;: mkdir /a: file exists.&#8221;</title>
		<link>https://myshittycode.com/2022/03/02/gcsfuse-docker-error-while-creating-mount-source-path-a-mkdir-a-file-exists/</link>
					<comments>https://myshittycode.com/2022/03/02/gcsfuse-docker-error-while-creating-mount-source-path-a-mkdir-a-file-exists/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Thu, 03 Mar 2022 00:34:34 +0000</pubDate>
				<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Google Cloud Platform]]></category>
		<category><![CDATA[Google Cloud Storage]]></category>
		<category><![CDATA[Google Cloud Storage FUSE]]></category>
		<guid isPermaLink="false">https://myshittycode.com/?p=1352</guid>

					<description><![CDATA[<p>This post illustrates how you can mount a GCS bucket using GCSFuse on your host machine and expose it as a volume to a Docker container. PROBLEM You want to volume mount a FUSE-mounted directory to a container, for example: When attempting to run the container&#8230; &#8230; an error occurred: SOLUTION Unmount the existing FUSE-mounted [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2022/03/02/gcsfuse-docker-error-while-creating-mount-source-path-a-mkdir-a-file-exists/">GCSFuse + Docker: &#8220;Error while creating mount source path &#8216;/a&#8217;: mkdir /a: file exists.&#8221;</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This post illustrates how you can mount a GCS bucket using GCSFuse on your host machine and expose it as a volume to a Docker container.</p>



<h2 class="wp-block-heading" id="problem">PROBLEM</h2>



<p>You want to volume mount a <a href="https://github.com/GoogleCloudPlatform/gcsfuse" target="_blank" rel="noopener">FUSE</a>-mounted directory to a container, for example:</p>



<figure class="wp-block-image size-large"><a href="https://myshittycode.com/wp-content/uploads/2022/03/aif_-2022-page-10-4.png?x45560"><img loading="lazy" decoding="async" width="888" height="560" src="https://myshittycode.com/wp-content/uploads/2022/03/aif_-2022-page-10-4.png?x45560" alt="" class="wp-image-1361" srcset="https://myshittycode.com/wp-content/uploads/2022/03/aif_-2022-page-10-4.png 888w, https://myshittycode.com/wp-content/uploads/2022/03/aif_-2022-page-10-4-300x189.png 300w, https://myshittycode.com/wp-content/uploads/2022/03/aif_-2022-page-10-4-768x484.png 768w" sizes="auto, (max-width: 888px) 100vw, 888px" /></a></figure>



<p>When attempting to run the container&#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
docker run -it --rm -v /my-kfc-bucket:/home busybox
</pre></div>


<p>&#8230; an error occurred:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
docker: Error response from daemon: error while creating
mount source path &#039;/my-kfc-bucket&#039;: mkdir /my-kfc-bucket: 
file exists.
</pre></div>


<h2 class="wp-block-heading" id="solution">SOLUTION</h2>



<p>Unmount the existing FUSE-mounted directory.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sudo umount /my-kfc-bucket
</pre></div>


<p>Mount it back with the following option. Because this command with <strong>-o allow_other</strong> must be executed with sudo privilege, you will need to change the root ownership to yourself (via <strong>&#8211;uid</strong> and <strong>&#8211;gid</strong>) so that you can easily read/write within the directory.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sudo gcsfuse \
  -o allow_other \
  --uid $(id -u) \
  --gid $(id -g) \
  gcs-bucket /my-kfc-bucket  
</pre></div>


<p>If it is successful, the output should look like this:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Start gcsfuse/0.40.0 (Go version go1.17.6) for app &quot;&quot; using mount point: /my-kfc-bucket
Opening GCS connection...
Mounting file system &quot;gcs-bucket&quot;...
File system has been successfully mounted.
</pre></div>


<p>Rerun the docker container.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
docker run -it --rm -v /my-kfc-bucket:/home busybox
</pre></div>


<p>Now, you can read/write the GCS bucket&#8217;s data from the container. In this example, the GCS bucket&#8217;s data is located in <strong>/home</strong>.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2022/03/02/gcsfuse-docker-error-while-creating-mount-source-path-a-mkdir-a-file-exists/">GCSFuse + Docker: &#8220;Error while creating mount source path &#8216;/a&#8217;: mkdir /a: file exists.&#8221;</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2022/03/02/gcsfuse-docker-error-while-creating-mount-source-path-a-mkdir-a-file-exists/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1352</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching 56/74 queries in 0.074 seconds using Disk

Served from: myshittycode.com @ 2026-02-18 08:45:19 by W3 Total Cache
-->