Skip to content
The Chat Archive
gpt-4.1-2025-04-14· OpenAI LMArena Human Preference 140K

How do I setup a service on nextcloud that will automatically pull the data from the ftp?

  1. User

    How do I setup a service on nextcloud that will automatically pull the data from the ftp?

  2. Assistant

    To set up a service on Nextcloud that automatically pulls data from an FTP server, you have a few options depending on your requirements and server access. Here’s a step-by-step guide for a common approach using External Storage and/or automation scripts.


    Option 1: Use Nextcloud External Storage App (Manual/On-Demand Access)

    Nextcloud has an External Storage app that allows you to mount FTP storage directly into Nextcloud. This does not automatically copy files into Nextcloud, but makes them accessible through the Nextcloud interface.

    Steps:

    1. Enable External Storage App:

      • Go to Apps in your Nextcloud admin interface.
      • Find and enable the External storage support app.
    2. Configure FTP Storage:

      • Go to Settings > Administration > External storages.
      • Add a new storage:
        • Folder name: (e.g., FTP-Data)
        • External storage: FTP
        • Configuration: Enter your FTP server details (host, username, password, etc.)
        • Available for: Select users/groups.
    3. Access Files:

      • Users will see the FTP folder in their Nextcloud files. Files are accessed on-demand, not copied.

    Option 2: Automatically Pull FTP Data into Nextcloud (Sync/Copy)

    If you want files to be automatically copied from FTP into Nextcloud (so they are indexed, available for sharing, etc.), you’ll need to set up a scheduled sync using a script (e.g., with lftp, curl, or wget) and then trigger Nextcloud to scan for new files.

    Steps:

    1. Create a Sync Script

    Example using lftp (on your Nextcloud server):

    #!/bin/bash
    
    # FTP credentials
    FTP_HOST="ftp.example.com"
    FTP_USER="ftpuser"
    FTP_PASS="ftppassword"
    
    # Local Nextcloud data directory for a user (e.g., 'admin')
    LOCAL_DIR="/var/www/nextcloud/data/admin/files/FTP-Import"
    
    # Sync files from FTP to local directory
    lftp -u $FTP_USER,$FTP_PASS $FTP_HOST <<EOF
    mirror --verbose /remote/path $LOCAL_DIR
    quit
    EOF
    
    # Set correct permissions (adjust as needed)
    chown -R www-data:www-data $LOCAL_DIR
    

    2. Schedule the Script

    • Make the script executable:
      chmod +x /path/to/ftp_sync.sh

    • Add to crontab for regular sync (e.g., every hour):

      0 * * * * /path/to/ftp_sync.sh
      

    3. Tell Nextcloud to Rescan Files

    After syncing, run:

    sudo -u www-data php /var/www/nextcloud/occ files:scan --path="admin/files/FTP-Import"
    

    Add this to your script after the sync step.


    Option 3: Use Nextcloud Workflow/Automation Apps

    Some Nextcloud apps (like Flow or Workflow scripts) can trigger actions on file changes, but they don’t natively support pulling from FTP. You’d still need an external script as above.


    Summary Table

    MethodProsCons
    External Storage AppEasy, no scripting neededFiles not copied, just mounted
    Scripted SyncFull control, files copiedRequires server access, scripting
    Workflow AppsAutomation on NextcloudNo native FTP pull, needs scripting

    Which Should You Use?

    • Just want access to FTP files in Nextcloud? Use External Storage.
    • Want files copied into Nextcloud, indexed, and available for sharing? Use a sync script + occ files:scan.

    Let me know if you need a ready-to-use script or help with a specific setup!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.