J. R. Swab

How To Automatically Sync Files To Nextcloud On Android

Categories: [Technology], [How To]

At the time of writing this post, the Nextcloud Android app does not have the ability to auto-sync files. The only auto-sync feature is for image directories but not anything other than that.

Heads Up:

I have noticed that editing the synced files within Nextcloud does not always work. However, viewing them has not given any problems so far.

Getting Files To Automatically Sync for View in Nextcloud:

  1. Create a directory on the Nextcloud server where the Android files will live.
  2. Set up an external storage for that new directory in Nextcloud:
    • settings -> "External storage"
    • Make sure Nextcloud can access the directory
  3. Install Syncthing to both your Android device and the Nextcloud server.
  4. On the Nextcloud server, run Syncthing to generate the default configuration file.
  5. ctrl-c to kill Syncthing
  6. Edit the config file to point to your new directory.
  7. Add you Android device to the Syncthing config file.
  8. Backup any data before you turn on Syncthing.
  9. Run Syncthing on the server: syncthing --no-browser (remove --no-browser if you want to access Syncthing via the Web GUI)

Syncthing Config File Example:

<configuration version="28">
        <folder id="xxxxx-xxxxx" label="Notes" path="/var/www/sync/notes" type="sendreceive" rescanIntervalS="3600" fsWatcherEnabled="true" fsWatcherDelayS="10" ignorePerms="false" autoNormalize="true">
        <filesystemType>basic</filesystemType>
        <device id="XXXX-XXXX-XXXX" introducedBy=""></device>
        <device id="XXXX-XXXX-XXXX" introducedBy=""></device>
        <minDiskFree unit="%">1</minDiskFree>
        <versioning></versioning>
        <copiers>0</copiers>
        <pullerMaxPendingKiB>0</pullerMaxPendingKiB>
        <hashers>0</hashers>
        <order>random</order>
        <ignoreDelete>false</ignoreDelete>
        <scanProgressIntervalS>0</scanProgressIntervalS>
        <pullerPauseS>0</pullerPauseS>
        <maxConflicts>-1</maxConflicts>
        <disableSparseFiles>false</disableSparseFiles>
        <disableTempIndexes>false</disableTempIndexes>
        <paused>false</paused>
        <weakHashThresholdPct>25</weakHashThresholdPct>
        <markerName>.stfolder</markerName>
        <useLargeBlocks>true</useLargeBlocks>
        <copyOwnershipFromParent>false</copyOwnershipFromParent>
    </folder>
    <device id="XXXX-XXXX-XXXX" name="server" compression="metadata" introducer="true" skipIntroductionRemovals="false" introducedBy="">
        <address>dynamic</address>
        <paused>false</paused>
        <autoAcceptFolders>false</autoAcceptFolders>
        <maxSendKbps>0</maxSendKbps>
        <maxRecvKbps>0</maxRecvKbps>
        <maxRequestKiB>0</maxRequestKiB>
    </device>
    <device id="XXXX-XXXX-XXXX-XXXX" name="android" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
        <address>dynamic</address>
        <paused>false</paused>
        <autoAcceptFolders>true</autoAcceptFolders>
        <maxSendKbps>0</maxSendKbps>
        <maxRecvKbps>0</maxRecvKbps>
        <maxRequestKiB>0</maxRequestKiB>
    </device>
    <gui enabled="false" tls="false" debugging="false">
        <address>127.0.0.1:8384</address>
        <apikey>xNsbPrJpAPzityVCwCuAhTFkzfERWMxa</apikey>
        <theme>default</theme>
    </gui>
    <ldap></ldap>
    <options>
        <listenAddress>default</listenAddress>
        <globalAnnounceServer>default</globalAnnounceServer>
        <globalAnnounceEnabled>true</globalAnnounceEnabled>
        <localAnnounceEnabled>true</localAnnounceEnabled>
        <localAnnouncePort>21027</localAnnouncePort>
        <localAnnounceMCAddr>[xxxx::xxxx]:21027</localAnnounceMCAddr>
        <maxSendKbps>0</maxSendKbps>
        <maxRecvKbps>0</maxRecvKbps>
        <reconnectionIntervalS>60</reconnectionIntervalS>
        <relaysEnabled>true</relaysEnabled>
        <relayReconnectIntervalM>10</relayReconnectIntervalM>
        <startBrowser>true</startBrowser>
        <natEnabled>true</natEnabled>
        <natLeaseMinutes>60</natLeaseMinutes>
        <natRenewalMinutes>30</natRenewalMinutes>
        <natTimeoutSeconds>10</natTimeoutSeconds>
        <urAccepted>0</urAccepted>
        <urSeen>0</urSeen>
        <urUniqueID></urUniqueID>
        <urURL>https://data.syncthing.net/newdata</urURL>
        <urPostInsecurely>false</urPostInsecurely>
        <urInitialDelayS>1800</urInitialDelayS>
        <restartOnWakeup>true</restartOnWakeup>
        <autoUpgradeIntervalH>12</autoUpgradeIntervalH>
        <upgradeToPreReleases>false</upgradeToPreReleases>
        <keepTemporariesH>24</keepTemporariesH>
        <cacheIgnoredFiles>false</cacheIgnoredFiles>
        <progressUpdateIntervalS>5</progressUpdateIntervalS>
        <limitBandwidthInLan>false</limitBandwidthInLan>
        <minHomeDiskFree unit="%">1</minHomeDiskFree>
        <releasesURL>https://upgrades.syncthing.net/meta.json</releasesURL>
        <overwriteRemoteDeviceNamesOnConnect>false</overwriteRemoteDeviceNamesOnConnect>
        <tempIndexMinBlocks>10</tempIndexMinBlocks>
        <trafficClass>0</trafficClass>
        <defaultFolderPath>~</defaultFolderPath>
        <setLowPriority>true</setLowPriority>
        <maxConcurrentScans>0</maxConcurrentScans>
    </options>
</configuration>

Happy Hacking!