2023-07-01 21:46:54 -05:00
---
title: "Command Lists"
weight: 2
description: >
2025-01-28 15:42:50 -06:00
This page tells you how to get use command lists.
2023-07-01 21:46:54 -05:00
---
Command lists are for executing commands in sequence and getting notifications from them.
The top-level object key can be anything you want but not the same as another.
2024-11-19 20:17:03 -06:00
Lists can go in a separate file. Command lists should be in a separate file if:
2025-02-08 15:17:34 -06:00
1. key 'cmd-lists.file' is specified
2. lists.yml or lists.yaml is found in the same directory as the backy config file
{{% notice info %}}
The lists file is also checked in remote resources.
The lists file is ignored under the following condition:
If a remote config file is specified (on the command-line using `-f` ) and the lists file is not found in the same directory, the lists file is assumed to not exist.
{{% /notice %}}
2024-11-19 20:17:03 -06:00
2025-01-28 15:42:50 -06:00
```yaml {lineNos="true" wrap="true" title="yaml"}
2023-07-01 21:46:54 -05:00
test2:
name: test2
order:
- test
- test2
notifications:
2023-09-08 23:42:13 -05:00
- mail.prod-email
- matrix.sysadmin
2023-07-01 21:46:54 -05:00
cron: "0 * * * * *"
```
| key | description | type | required
| --- | --- | --- | --- |
| `order` | Defines the sequence of commands to execute | `[]string` | yes |
| `getOutput` | Command(s) output is in the notification(s) | `bool` | no |
2023-09-08 23:42:13 -05:00
| `notifications` | The notification service(s) and ID(s) to use on success and failure. Must be *`service.id`* . See the [notifications documentation page ](/config/notifications/ ) for more | `[]string` | no |
2023-07-01 21:46:54 -05:00
| `name` | Optional name of the list | `string` | no |
2023-09-08 23:42:13 -05:00
| `cron` | Time at which to schedule the list. Only has affect when cron subcommand is run. | `string` | no |
2023-07-01 21:46:54 -05:00
### Order
The order is an array of commands to execute in order. Each command must be defined.
```yaml
order:
- cmd-1
- cmd-2
```
### getOutput
Get command output when a notification is sent.
2023-09-08 23:42:13 -05:00
Is not required. Can be `true` or `false` . Default is `false` .
2023-07-01 21:46:54 -05:00
### Notifications
An array of notification IDs to use on success and failure. Must match any of the `notifications` object map keys.
### Name
2024-11-19 20:17:03 -06:00
Name is optional. If name is not defined, name will be the object's map key.
2023-07-01 21:46:54 -05:00
### Cron mode
Backy also has a cron mode, so one can run `backy cron` and start a process that schedules jobs to run at times defined in the configuration file.
2023-09-08 23:42:13 -05:00
Adding `cron: 0 0 1 * * *` to a `cmd-lists` object will schedule the list at 1 in the morning. See [https://crontab.guru/ ](https://crontab.guru/ ) for reference.
2023-07-01 21:46:54 -05:00
{{% notice tip %}}
2025-01-28 15:42:50 -06:00
Note: Backy uses the second field of cron, so add anything except `*` to the beginning of a regular cron expression.
2023-07-01 21:46:54 -05:00
{{% /notice %}}
2025-01-28 15:42:50 -06:00
```yaml {lineNos="true" wrap="true" title="yaml"}
2023-09-08 23:42:13 -05:00
cmd-lists:
docker-container-backup: # this can be any name you want
2023-07-01 21:46:54 -05:00
# all commands have to be defined
order:
- stop-docker-container
- backup-docker-container-script
- shell-cmd
- hostname
2023-09-08 23:42:13 -05:00
- start-docker-container
2023-07-01 21:46:54 -05:00
notifications:
2023-09-08 23:42:13 -05:00
- matrix.id
name: backup-some-container
2023-07-01 21:46:54 -05:00
cron: "0 0 1 * * *"
hostname:
name: hostname
order:
- hostname
notifications:
2023-09-08 23:42:13 -05:00
- mail.prod-email
2023-07-01 21:46:54 -05:00
```