{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"params":[]},"next":{"description":"","pages":[]},"title":"Specify default values","type":"basic","slug":"specify-default-values","excerpt":"Specify default option values for backup agents : commands, transports and notifiers","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: \\\"[email protected]\\\"\\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: \\\"[email protected]\\\",\\n  to: \\\"[email protected]\\\"\\n\\njob \\\"my-backup\\\" do\\n  notify via: \\\"email\\\", to: \\\"[email protected]\\\"\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]","updates":[],"order":2,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"54fda39021538c21006c49b9","category":{"sync":{"isSync":false,"url":""},"pages":["54fda39021538c21006c49b6","54fda39021538c21006c49b7","54fda39021538c21006c49b8","54fda39021538c21006c49b9","54fda39021538c21006c49ba","54fda39021538c21006c49bb","54fda5d10c05ea25004ce0cd","5582f41f81672a3900bb4fe9"],"title":"Documentation","slug":"documentation","order":0,"from_sync":false,"reference":false,"_id":"54fda38f21538c21006c49a7","createdAt":"2014-11-08T14:11:40.826Z","project":"545e249c7ca5470800b3a1b2","version":"54fda38e21538c21006c49a6","__v":3},"githubsync":"","__v":0,"project":"545e249c7ca5470800b3a1b2","createdAt":"2014-12-30T12:02:08.567Z","user":"545e246f7ca5470800b3a1b1","version":{"version":"0.5.0","version_clean":"0.5.0","codename":"","is_stable":true,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["54fda38f21538c21006c49a7","54fda38f21538c21006c49a8","54fda38f21538c21006c49a9","54fda38f21538c21006c49aa","54fda38f21538c21006c49ab","54fda3d347f93619001d2ae2","54fea8975c4ab10d00ef4279"],"_id":"54fda38e21538c21006c49a6","__v":3,"createdAt":"2015-03-09T13:43:42.927Z","forked_from":"54eb4535615ffc19003059f0","project":"545e249c7ca5470800b3a1b2","releaseDate":"2015-03-09T13:43:42.927Z"}}

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: \"[email protected]\",\n to: \"[email protected]\"\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: \"[email protected]\",\n to: \"[email protected]\"\n\njob \"my-backup\" do\n notify via: \"email\", to: \"[email protected]\"\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block]