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