{"_id":"54fda39021538c21006c49b9","category":{"_id":"54fda38f21538c21006c49a7","project":"545e249c7ca5470800b3a1b2","version":"54fda38e21538c21006c49a6","__v":3,"pages":["54fda39021538c21006c49b6","54fda39021538c21006c49b7","54fda39021538c21006c49b8","54fda39021538c21006c49b9","54fda39021538c21006c49ba","54fda39021538c21006c49bb","54fda5d10c05ea25004ce0cd","5582f41f81672a3900bb4fe9"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-11-08T14:11:40.826Z","from_sync":false,"order":0,"slug":"documentation","title":"Documentation"},"githubsync":"","__v":0,"project":"545e249c7ca5470800b3a1b2","user":"545e246f7ca5470800b3a1b1","version":{"_id":"54fda38e21538c21006c49a6","__v":3,"forked_from":"54eb4535615ffc19003059f0","project":"545e249c7ca5470800b3a1b2","createdAt":"2015-03-09T13:43:42.927Z","releaseDate":"2015-03-09T13:43:42.927Z","categories":["54fda38f21538c21006c49a7","54fda38f21538c21006c49a8","54fda38f21538c21006c49a9","54fda38f21538c21006c49aa","54fda38f21538c21006c49ab","54fda3d347f93619001d2ae2","54fea8975c4ab10d00ef4279"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.5.0","version":"0.5.0"},"metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-12-30T12:02:08.567Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"Although option values for backup commands, transport protocols and notifiers can be set at the agent-level, assigning default values is a convenient way to define settings globally. For example, there is a good chance you'll want your email delivery settings to be to be shared by all your jobs.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Specifying defaults\"\n}\n[/block]\nTo specify default values, use the `defaults_for` verb in your _Sheepfile_, then indicate the type and name of the agent and the desired options:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"defaults_for command: \\\"mysql_dump\\\",\\n\\tuser: \\\"backup\\\",\\n\\tpassword: encrypted(\\\"encrypted_password\\\")\\n\\ndefaults_for transport: \\\"s3\\\",\\n\\taccess_key_id: \\\"ABCDEF\\\",\\n\\tsecret_key: encrypted(\\\"encrypted_secret\\\")\\n\\ndefaults_for notifier: \\\"email\\\",\\n\\tusing: \\\"sendmail\\\",\\n  from: \\\"robots:::at:::example.com\\\",\\n  to: \\\"devops@example.com\\\"\\n\\nhost \\\"my-app-host\\\", hostname: \\\"host.example.com\\\"\\n\\njob \\\"my-db-backup\\\" do\\n  resource \\\"database\\\", name: \\\"my-database\\\", host: \\\"my-app-host\\\"\\n  remotely as: \\\"user\\\" do\\n    mysql_dump # Use default user and password\\n    tar_gz delete_source: true\\n  end\\n  move to: \\\"localhost\\\", using: \\\"scp\\\", as: \\\"user\\\"\\n  copy to: \\\"my-bucket/my-project\\\", using: \\\"s3\\\" # Use default credentials\\n  notify via: \\\"email\\\" # Use default delivery settings \\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\nRefer to the documentation of individual commands, transports and notifiers for the list of all available options.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"A word of warning\",\n  \"body\": \"You'd better avoid assigning default values to destructive options and define them explicitely at the agent-level. For example, the `delete_source` option of the `tar_gz` command deletes its input after execution. It could be the desired behavior but defining it globally may be risky, especially if your _Sheepfile_ contains a lot of jobs.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Overriding default values\"\n}\n[/block]\nTo override default values, simply redefine them at the agent-level:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"defaults_for notifier: \\\"email\\\",\\n\\tusing: \\\"sendmail\\\",\\n  from: \\\"robots@example.com\\\",\\n  to: \\\"devops@example.com\\\"\\n\\njob \\\"my-backup\\\" do\\n  notify via: \\\"email\\\", to: \\\"another-address@example.com\\\"\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]","excerpt":"Specify default option values for backup agents : commands, transports and notifiers","slug":"specify-default-values","type":"basic","title":"Specify default values"}

Specify default values

Specify default option values for backup agents : commands, transports and notifiers

Although option values for backup commands, transport protocols and notifiers can be set at the agent-level, assigning default values is a convenient way to define settings globally. For example, there is a good chance you'll want your email delivery settings to be to be shared by all your jobs. [block:api-header] { "type": "basic", "title": "Specifying defaults" } [/block] To specify default values, use the `defaults_for` verb in your _Sheepfile_, then indicate the type and name of the agent and the desired options: [block:code] { "codes": [ { "code": "defaults_for command: \"mysql_dump\",\n\tuser: \"backup\",\n\tpassword: encrypted(\"encrypted_password\")\n\ndefaults_for transport: \"s3\",\n\taccess_key_id: \"ABCDEF\",\n\tsecret_key: encrypted(\"encrypted_secret\")\n\ndefaults_for notifier: \"email\",\n\tusing: \"sendmail\",\n from: \"robots@example.com\",\n to: \"devops@example.com\"\n\nhost \"my-app-host\", hostname: \"host.example.com\"\n\njob \"my-db-backup\" do\n resource \"database\", name: \"my-database\", host: \"my-app-host\"\n remotely as: \"user\" do\n mysql_dump # Use default user and password\n tar_gz delete_source: true\n end\n move to: \"localhost\", using: \"scp\", as: \"user\"\n copy to: \"my-bucket/my-project\", using: \"s3\" # Use default credentials\n notify via: \"email\" # Use default delivery settings \nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] Refer to the documentation of individual commands, transports and notifiers for the list of all available options. [block:callout] { "type": "danger", "title": "A word of warning", "body": "You'd better avoid assigning default values to destructive options and define them explicitely at the agent-level. For example, the `delete_source` option of the `tar_gz` command deletes its input after execution. It could be the desired behavior but defining it globally may be risky, especially if your _Sheepfile_ contains a lot of jobs." } [/block] [block:api-header] { "type": "basic", "title": "Overriding default values" } [/block] To override default values, simply redefine them at the agent-level: [block:code] { "codes": [ { "code": "defaults_for notifier: \"email\",\n\tusing: \"sendmail\",\n from: \"robots@example.com\",\n to: \"devops@example.com\"\n\njob \"my-backup\" do\n notify via: \"email\", to: \"another-address@example.com\"\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block]