github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/commands/operator/snapshot/agent.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: 'Commands: operator snapshot agent'
     4  description: |
     5    Periodically saves snapshots of Nomad server state
     6  ---
     7  
     8  # Command: operator snapshot agent
     9  
    10  <EnterpriseAlert />
    11  
    12  The snapshot agent takes snapshots of the state of the nomad servers and
    13  saves them locally, or pushes them to an optional remote storage service.
    14  
    15  The agent can be run as a long-running daemon process or in a one-shot mode
    16  from a batch job. As a long-running daemon, the agent will perform a leader
    17  election so multiple processes can be run in a highly available fashion with
    18  automatic failover. In daemon mode, the agent will also register itself with
    19  Consul as a service, along with health checks that show the agent is alive
    20  and able to take snapshots.
    21  
    22  If ACLs are enabled, a management token must be supplied in order to perform
    23  snapshot operations.
    24  
    25  The Config file has the following format (shown populated with default values):
    26  
    27  ```hcl
    28  nomad {
    29    address         = "http://127.0.0.1:4646"
    30    token           = ""
    31    region          = ""
    32    ca_file         = ""
    33    ca_path         = ""
    34    cert_file       = ""
    35    key_file        = ""
    36    tls_server_name = ""
    37  }
    38  
    39  
    40  snapshot {
    41    interval         = "1h"
    42    retain           = 30
    43    stale            = false
    44    service          = "nomad-snapshot"
    45    deregister_after = "72h"
    46    lock_key         = "nomad-snapshot/lock"
    47    max_failures     = 3
    48    prefix           = "nomad"
    49  }
    50  
    51  log {
    52    level           = "INFO"
    53    enable_syslog   = false
    54    syslog_facility = "LOCAL0"
    55  }
    56  
    57  consul {
    58    enabled         = true
    59    http_addr       = "127.0.0.1:8500"
    60    token           = ""
    61    datacenter      = ""
    62    ca_file         = ""
    63    ca_path         = ""
    64    cert_file       = ""
    65    key_file        = ""
    66    tls_server_name = ""
    67  }
    68  
    69  # one storage block is required
    70  
    71  local_storage {
    72    path = "."
    73  }
    74  
    75  aws_storage {
    76    access_key_id     = ""
    77    secret_access_key = ""
    78    s3_region         = ""
    79    s3_endpoint       = ""
    80    s3_bucket         = ""
    81    s3_key_prefix     = "nomad-snapshot"
    82  }
    83  
    84  azure_blob_storage {
    85    account_name   = ""
    86    account_key    = ""
    87    container_name = ""
    88  }
    89  
    90  google_storage {
    91    bucket = ""
    92  }
    93  ```
    94  
    95  ## Usage
    96  
    97  ```plaintext
    98  nomad operator snapshot agent [options] <config_file>
    99  ```
   100  
   101  ## General Options
   102  
   103  @include 'general_options_no_namespace.mdx'
   104  
   105  ## Snapshot agent Options
   106  
   107  ### Snapshot Options
   108  
   109  - `-interval`: Interval at which to perform snapshots as a time with a unit suffix, which can be "s", "m", "h" for seconds, minutes, or hours. If 0 is provided, the agent will take a single snapshot and then exit, which is useful for running snapshots via batch jobs. Defaults to "1h".
   110  - `-lock-key`: A prefix in Consul's key-value store used to coordinate between different instances of the snapshot agent in order to only have one active instance at a time. For highly available operation of the snapshot agent, simply run multiple instances. All instances must be configured with the same lock key in order to properly coordinate. Defaults to "nomad-snapshot/lock".
   111  - `-max-failures`: Number of snapshot failures after which the snapshot agent will give up leadership. In a highly available operation with multiple snapshot agents available, this gives another agent a chance to take over if an agent is experiencing issues, such as running out of disk space for snapshots. Defaults to 3.
   112  - `-retain`: Number of snapshots to retain. After each snapshot is taken, the oldest snapshots will start to be deleted in order to retain at most this many snapshots. If this is set to 0, the agent will not perform this and snapshots will accumulate forever. Defaults to 30.
   113  
   114  ### Agent Options
   115  
   116  - `-deregister-after`: An interval, after which if the agent is unhealthy it will be automatically deregistered from Consul service. discovery. This is a time with a unit suffix, which can be "s", "m", "h" for seconds, minutes, or hours. If 0 is provided, this will be disabled. Defaults to "72h".
   117  - `-log-level`: Controls verbosity of snapshot agent logs. Valid options are "TRACE", "DEBUG", "INFO", "WARN", "ERR". Defaults to "INFO".
   118  - `-log-json`: Output logs in JSON format. Defaults to false.
   119  - `-service`: The service name to used when registering the agent with Consul. Registering helps monitor running agents and the leader registers an additional health check to monitor that snapshots are taking place. Defaults to "nomad-snapshot".
   120  - `-syslog`: This enables forwarding logs to syslog. Defaults to false.
   121  - `-syslog-facility`: Sets the facility to use for forwarding logs to syslog. Defaults to "LOCAL0".
   122  
   123  ### Local Storage Options
   124  
   125  - `-local-path`: Location to store snapshots locally. The default behavior of the snapshot agent is to store snapshots locally in this directory. Defaults to "." to use the current working directory. If an alternate storage option is configured, then local storage will be disabled and this option will be ignored.
   126  
   127  ### S3 Storage Options:
   128  
   129  Note that despite the AWS references, any S3-compatible endpoint can be specified with '-aws-s3-endpoint'.
   130  
   131  - `-aws-access-key-id`: These arguments supply authentication information for
   132  - `-aws-secret-access-key`: connecting to S3. These may also be supplied using the following alternative methods:
   133    - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
   134    - A credentials file (~/.aws/credentials or the file at the path specified by the AWS_SHARED_CREDENTIALS_FILE environment variable)
   135    - ECS task role metadata (container-specific)
   136    - EC2 instance role metadata
   137  - `-aws-s3-bucket`: S3 bucket to use. Required for S3 storage, and setting this disables local storage.
   138  - `-aws-s3-key-prefix`: Prefix to use for snapshot files in S3. Defaults to "nomad-snapshot".
   139  - `-aws-s3-region`: S3 region to use. Required for S3 storage.
   140  - `-aws-s3-endpoint`: Optional S3 endpoint to use. Can also be specified using the AWS_S3_ENDPOINT environment variable.
   141  - `-aws-s3-server-side-encryption`: Enables server side encryption with AES-256, when storing snapshots to S3. Defaults to false.
   142  - `-aws-s3-static-snapshot-name`: Static file name to use for snapshot files. If this is set, snapshots are always saved with the same name, and are not versioned or rotated.
   143  - `-aws-s3-enable-kms`: Enables using Amazon KMS for encrypting snapshots
   144  - `-aws-s3-kms-key`: Optional KMS key to use, if this is not set the default KMS key will be used.
   145  
   146  ### Azure Blob Storage Options
   147  
   148  (Note: Non-Solaris platforms only)
   149  
   150  - `-azure-blob-account-name`: These arguments supply authentication information
   151  - `-azure-blob-account_key`: for connecting to Azure Blob storage.
   152  - `-azure-blob-container-name`: Container to use. Required for Azure blob storage, and setting this disables local storage.
   153  - `-azure-blob-environment`: Environment to use. Defaults to AZUREPUBLICCLOUD. Other valid environments are AZURECHINACLOUD, AZUREGERMANCLOUD and AZUREUSGOVERNMENTCLOUD.
   154  
   155  ### Google Storage Options
   156  
   157  - `-google-bucket`: The bucket to use.