# Archive Files to FTP Server

Cloud Voice can copy your call recordings and system backups to an external FTP (File Transfer Protocol) server, either as a one-off transfer or on a repeating schedule. To set this up, you first register the FTP server as an archive destination and then create a task that decides which files are sent and when.

## Requirements

- **PBX firmware**: Version 84.22.0.17 or later.
- **Plan**: Enterprise Plan (self-managed deployment) or Ultimate Plan (Cloud Voice-hosted deployment).

## Limits

- Up to 10 archive servers.
- Up to 200 archive tasks.

## Before you begin

Gather the following so the connection can be configured without interruption:

- An FTP server. Have its **domain or IP address**, **port**, and **file transfer protocol** ready.
- An FTP account that can both read and write. Note its **username** and **password**.

:::note
If you want Cloud Voice to remove old files from the server automatically, the FTP account also needs permission to delete files.
:::

## Step 1: Register the FTP server as an archive server

1. Sign in to the web portal and go to **System > Archive**.
2. On the **Archive Task** tab, click **Archive Server**.

   ![Archive Task tab with the Archive Server button highlighted](/images/pbx/click-archive-server.png)

3. Click **Add** and fill in the dialog:

   ![Dialog for defining an FTP archive server with connection and credential fields](/images/pbx/ftp-archive-server-setting.png)

   - **Name**: A label that helps you recognize this server.
   - **Server Type**: Select **FTP**.
   - **FTP Server Domain/IP**: The address of your FTP server.
   - **Port**: The port the server listens on. The default is 21.
   - **File Transfer Protocol**: Choose the protocol your server supports:
     - **FTP**: Standard File Transfer Protocol.
     - **FTPES**: FTP secured with explicit TLS/SSL (Transport Layer Security), which encrypts the connection.

       :::note
       - TLS must be turned on and its encryption policy properly configured on the FTP server.
       - Only TLS v1.2 is supported.
       :::
   - **Username**: The FTP account username.
   - **Password**: The password for that account.
4. Click **Save**. The server now appears in the archive server list.
5. Close the window.

## Step 2: Create an archive task

1. On the **Archive Task** tab, click **Add**.
2. Complete the **Task Configuration** section:

   ![Task Configuration section with the task name, file type, date range, and schedule fields](/images/pbx/s3-archive-task.png)

   - **Name**: A label that helps you recognize this task.
   - **File Type**: Choose **Recording Files** or **Backup Files**.
   - **Data Range**: The time span of files to include. You can cover up to 31 days per task.
   - **Sync Frequency**: How often the task runs:
     - **Once**: Archives the files as soon as you save the task.
     - **Daily**: Runs each day at a time you select.
     - **Weekly**: Runs on a chosen day of the week at a chosen time.
     - **Monthly**: Runs on a chosen day of the month at a chosen time.

     :::caution
     Archiving large volumes of data draws on the system's CPU. Schedule recurring tasks for off-peak hours.
     :::
   - **Recording File Format**: The download format for recordings. This field appears only for recording-file tasks, and every recording in the system is downloaded and stored in the format you pick.
3. Complete the **Storage Configuration** section:
   - **Archive Server**: Select the FTP server you registered in Step 1.
   - **Select Folder/Path**: Optional. The folder that receives the files, for example `pbx/backup/`. Leave it empty to use the root directory.
   - **Storage Method**: How files are laid out on the server. The available options depend on whether the task runs once or repeats.

     For a one-time task:
     - **Create Task Folder**: Creates a folder named `FileType-TaskName` under the path and stores the files there.
     - **Save Directly to Selected Path**: Writes the files straight to the path with no folder.

     For a recurring task:
     - **Create Folder per Execution**: Creates a folder named `FileType-TaskName-ExecutionDate` under the path on every run.
     - **Create Task Folder Once and Reuse It**: Creates a folder named `FileType-TaskName` on the first run and reuses it for later runs.
     - **Save Directly to Selected Path**: Writes files straight to the path on every run, with no folder.
   - **Skip archived files**: Optional, and available only for recording-file tasks. When enabled, files already archived are left out. When disabled, they are archived again: the stored location is refreshed, but the earlier copy on the server is not removed.
   - **Delete local files after archiving**: Optional, and available only for recording-file tasks. When enabled, local copies are removed once archived; the recordings stay playable and downloadable from the admin portal and the Cloud Voice App, but are no longer available for playback or download on the third-party server or in Microsoft Dynamics 365. When disabled, local copies are kept.
   - **Organize Files by Date**: Optional. When enabled, the system adds date subfolders named `YYYYMMDD` (for example, `20260301`) under the storage path. When disabled, files go directly into the path.

     :::note
     If the selected date range holds only a single record, no date subfolder is created and the file is stored directly in the path.
     :::
4. Optional: set a retention policy so older archives are cleaned up automatically.

   :::note
   - This section appears only for recurring tasks.
   - The FTP account must have permission to delete resources on the server.
   :::

   ![Retention settings with retention type, limit, and unit fields](/images/pbx/archive-retention-settings.png)

   - **Retention Type**:
     - **Retention by Quantity**: Keeps a maximum number of files or folders in the storage path. Enter the ceiling in **Retention Limit (files/folders)**; once it is exceeded, the oldest items are deleted.
     - **Retention by Days**: Keeps files or folders for a maximum period. Enter the number of days in **Retention Limit (in days)**; anything older is deleted.

       :::note
       - The period is counted from the time a file is archived to the server, not from when it was created on the system.
       - Days are measured as exact 24-hour intervals, not calendar days.
       :::
   - **Retention Limit**: The maximum number of files or folders, or the maximum number of days, depending on the retention type.
   - **Retention Unit**:
     - **Folder**: Applies to the task folders created on the server. This is available only when **Storage Method** is **Create Folder per Execution**, and it does not count the date subfolders produced by **Organize Files by Date**.
     - **File**: Applies to the individual archived files.
5. Click **Save**.

## Result

The selected files are copied to the target folder on your FTP server, either right away or at the scheduled time.

:::note
The system runs one task at a time to protect performance. When several tasks are due, they run one after another in a queue.
:::

You can confirm the outcome in two places.

**In Cloud Voice**: Go to **System > Archive > Archival Logs**. A **Succeeded** value in the **Result** column means the files reached the FTP server.

![Archival Logs list showing task results](/images/pbx/archival-logs.png)

If a task fails, the **Failed to Archive File(s)** event is raised. Use the retry control on the log entry to run it again.

![Archival log entry with the retry control for a failed task](/images/pbx/retry-archive-task.png)

**On the FTP server**: Open the target folder. If the expected files are listed, the archive succeeded.

![Archived recording files listed in the destination folder on the FTP server](/images/pbx/recording-file-on-ftp.png)
