{"_id":"54fda39021538c21006c49b8","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"},"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"},"__v":2,"githubsync":"","project":"545e249c7ca5470800b3a1b2","updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-11-29T16:00:19.890Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"never","params":[],"url":""},"isReference":false,"order":1,"body":"You may use any scheduler to launch ElectricSheep.IO runs, such as Cron or Chronos. However, we think that the scheduling options for your backups should be:\n\n* simple to read and configure: there's a 99% chance you'll want your backups to execute hourly or daily at a specific time\n* come along your backup jobs: not in a crontab lost somewhere on your filesystem\n\nElectricSheep.IO thus provides you with an easy, built-in and human-readable way of scheduling your backups. To do so, specify a schedule for each of your job directly in your _Sheepfile_:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"daily\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\nThen start the program as a daemon:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"electric_sheep start -d\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nThat's it! Your backup project will execute every day at midnight, starting tonight.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Scheduling options\"\n}\n[/block]\n### Hourly\n\nTo run your job every hour:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"hourly\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\nIf you want your backup to start past a specific minute, use the `past` option (defaults to `0`):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"hourly\\\", past: 10\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\n### Daily\n\nTo run your job every day at midnight:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"daily\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\nIf you want your backup to start at a specific time:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"daily\\\", at: \\\"03:17\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\n### Weekly\n\nTo run your job every monday at midnight:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"weekly\\\", on: \\\"monday\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\nIf you want your backup to start at a specific time:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"weekly\\\", on: \\\"monday\\\", at: \\\"04:00\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\n### Monthly\n\nTo run your prjoboject every fifteenth of a month:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"monthly\\\", every: 15\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\nIf you want your backup to start at a specific time:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"monthly\\\", every: 15, at: \\\"04:00\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]\n### Cron\n\nTo setup a complex schedule, you may use Cron expressions:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"cron\\\", expression: \\\"* 1 * * *\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Multiple schedules\"\n}\n[/block]\nYou may need to schedule a backup job multiple times, for example every 6 hours. To do so, simply use the `schedule` verb multiple times:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"job \\\"my-backup\\\" do\\n  schedule \\\"daily\\\", at: \\\"00:00\\\"\\n  schedule \\\"daily\\\", at: \\\"06:00\\\"\\n  schedule \\\"daily\\\", at: \\\"12:00\\\"\\n  schedule \\\"daily\\\", at: \\\"18:00\\\"\\n  ...\\nend\",\n      \"language\": \"ruby\",\n      \"name\": \"Sheepfile\"\n    }\n  ]\n}\n[/block]","excerpt":"Ensure backups are done in a consistent and timely manner","slug":"schedule-your-backups","type":"basic","title":"Schedule your backups"}

Schedule your backups

Ensure backups are done in a consistent and timely manner

You may use any scheduler to launch ElectricSheep.IO runs, such as Cron or Chronos. However, we think that the scheduling options for your backups should be: * simple to read and configure: there's a 99% chance you'll want your backups to execute hourly or daily at a specific time * come along your backup jobs: not in a crontab lost somewhere on your filesystem ElectricSheep.IO thus provides you with an easy, built-in and human-readable way of scheduling your backups. To do so, specify a schedule for each of your job directly in your _Sheepfile_: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"daily\"\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] Then start the program as a daemon: [block:code] { "codes": [ { "code": "electric_sheep start -d", "language": "shell" } ] } [/block] That's it! Your backup project will execute every day at midnight, starting tonight. [block:api-header] { "type": "basic", "title": "Scheduling options" } [/block] ### Hourly To run your job every hour: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"hourly\"\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] If you want your backup to start past a specific minute, use the `past` option (defaults to `0`): [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"hourly\", past: 10\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] ### Daily To run your job every day at midnight: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"daily\"\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] If you want your backup to start at a specific time: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"daily\", at: \"03:17\"\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] ### Weekly To run your job every monday at midnight: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"weekly\", on: \"monday\"\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] If you want your backup to start at a specific time: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"weekly\", on: \"monday\", at: \"04:00\"\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] ### Monthly To run your prjoboject every fifteenth of a month: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"monthly\", every: 15\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] If you want your backup to start at a specific time: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"monthly\", every: 15, at: \"04:00\"\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block] ### Cron To setup a complex schedule, you may use Cron expressions: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"cron\", expression: \"* 1 * * *\"\n ...\nend", "language": "ruby" } ] } [/block] [block:api-header] { "type": "basic", "title": "Multiple schedules" } [/block] You may need to schedule a backup job multiple times, for example every 6 hours. To do so, simply use the `schedule` verb multiple times: [block:code] { "codes": [ { "code": "job \"my-backup\" do\n schedule \"daily\", at: \"00:00\"\n schedule \"daily\", at: \"06:00\"\n schedule \"daily\", at: \"12:00\"\n schedule \"daily\", at: \"18:00\"\n ...\nend", "language": "ruby", "name": "Sheepfile" } ] } [/block]