> ## Documentation Index
> Fetch the complete documentation index at: https://docs.germainux.com/llms.txt
> Use this file to discover all available pages before exploring further.

# File Archiving

> GermainUX can archive files automatically on a configured schedule.

Components
[`Engine`](https://docs.germainux.com/main/germain-ux-engine)

Availability
2014.1 or later

> **[Configuration](#configuration)**
>
> Archive schedule and paths

> **[Safety and Validation](#safety-and-validation)**
>
> Preview files before deleting

**Automate File Archiving**

GermainUX can archive files automatically on a configured schedule. For example, an Executor component can compress log files older than a specified number of days, move the archives to another location, and remove the original files after successful archival.

Executor components can run commands locally or through a remote GermainUX Engine. Their output can also be processed by a Drools rule when additional analysis, validation, or data extraction is required.

## Configuration

### 1 Step 1: Create a Local Executor Component

Create a component of type **Local Executor** and configure the archive command.

![File Archiving: 1 Step 1: Create a Local Executor Component](https://mintcdn.com/germain-ux/8KX3c-GSSWR99tdN/images/main/file-archiving/image-20230519-083531.png?fit=max\&auto=format\&n=8KX3c-GSSWR99tdN\&q=85\&s=f5e20fc8970e5351afa80091e3bb20e5)

The following example:

* Searches the source directory.
* Selects files matching the configured filename pattern.
* Selects files older than the retention period.
* Compresses each file as a `.tar.gz` archive.
* Moves the archive to the target directory.
* Removes the original file only after the archive has been created and moved successfully.

```bash theme={null}
cd "${SourceLocation}" &&
find . \
  -maxdepth 1 \
  -type f \
  -mtime +"${RetentionDays}" \
  -name "${FilePattern}" \
  -exec sh -c '
    target="$1"
    shift

    for file do
      archive="${file}.tar.gz"

      tar -czf "$archive" -- "$file" &&
      mv -- "$archive" "$target/" &&
      rm -- "$file"
    done
  ' sh "${TargetLocation}" {} +
```

### Deployment References

Configure the following values as references when deploying the component:

| Reference | Description |
| - | - |
| **SourceLocation** | Directory containing the files to archive. |
| **RetentionDays** | Minimum file age, in days, before a file is archived. |
| **FilePattern** | Shell filename pattern used to select files. |
| **TargetLocation** | Directory to which completed archives are moved. |

`FilePattern` uses shell wildcard matching rather than a regular expression.

### Example Values

```text theme={null}
SourceLocation : /siebel/Siebel/ai/applicationcontainer_external/logs
RetentionDays  : 14
FilePattern    : *.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].log
TargetLocation : /siebel/bfs/AILogsBKP/AINode4
```

This example archives matching log files more than 14 days old.

### 2 Step 2: Deploy the Component

Deploy the Local Executor component to the required GermainUX Engine:

* Select the target Monitoring Node and Engine.
* Configure the deployment references.
* Set the execution interval.
* Deploy the component.
* Run it manually once to validate the configuration.
* Confirm that the archives were created and moved successfully.
* Enable the recurring schedule.   ![File Archiving: 2 Step 2: Deploy the Component](https://mintcdn.com/germain-ux/8KX3c-GSSWR99tdN/images/main/file-archiving/image-20230519-084257.png?fit=max\&auto=format\&n=8KX3c-GSSWR99tdN\&q=85\&s=0d6ee6609a3612acc7e0c66613924a2f)

## Safety and Validation

This automation deletes source files after successful archival. Before enabling the schedule:

* Confirm that `SourceLocation` and `TargetLocation` resolve to the intended directories.
* Confirm that the target directory exists and is writable.
* Test the filename pattern with `find` before enabling deletion.
* Use a nonproduction directory for the first test.
* Confirm that generated archives can be opened.
* Verify available disk space in both locations.
* Ensure that no application still requires access to the selected files.
* Run the Engine under an account with only the permissions required for this task.

To preview the files that would be selected without modifying them, run:

```bash theme={null}
cd "${SourceLocation}" &&
find . \
  -maxdepth 1 \
  -type f \
  -mtime +"${RetentionDays}" \
  -name "${FilePattern}" \
  -print
```

## Get Help

> **[Contact GermainUX Support](https://docs.germainux.com/main/support.md)**
>
> The Germain Team can help you set this up.

> **Can't find what you need?**
>
> Search all GermainUX docs with **Ctrl + K**, or use the feedback buttons at the bottom of this page to tell us what is missing.

The content of this document is proprietary to GERMAIN SOFTWARE.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.