{"id":15959098,"url":"https://github.com/nickstenning/azure-mail-backup","last_synced_at":"2025-04-04T10:51:42.069Z","repository":{"id":66096401,"uuid":"200642137","full_name":"nickstenning/azure-mail-backup","owner":"nickstenning","description":"A system for making a backup of an email account in Azure","archived":false,"fork":false,"pushed_at":"2023-10-08T12:43:43.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T21:11:28.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nickstenning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-05T11:25:25.000Z","updated_at":"2022-03-07T10:12:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"41270081-c4ed-4078-89b6-3b4c78eab55c","html_url":"https://github.com/nickstenning/azure-mail-backup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickstenning%2Fazure-mail-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickstenning%2Fazure-mail-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickstenning%2Fazure-mail-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickstenning%2Fazure-mail-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickstenning","download_url":"https://codeload.github.com/nickstenning/azure-mail-backup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166147,"owners_count":20894652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-07T14:40:20.596Z","updated_at":"2025-04-04T10:51:42.052Z","avatar_url":"https://github.com/nickstenning.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Azure mail backup\n\nThis repository contains the tools and configuration for my automatic mail\nbackup system.\n\nFor years I've synced my mail to a local [Maildir] using the wonderful\n[OfflineIMAP]. This Maildir is also a git repository, which allows me to\nreproduce the state of my mailbox at any point in the past, and gives me a great\ndeal of confidence that none of the backup tooling will accidentally lose email.\n\nUntil recently, this setup has been running on a VM in [Linode] which was up\n24/7/365. This repository contains the code necessary to set up a VM in Azure\nwhich serves the same purpose and runs only when needed.\n\n[Linode]: https://www.linode.com\n[Maildir]: https://en.wikipedia.org/wiki/Maildir\n[OfflineIMAP]: https://www.offlineimap.org\n\n## Design\n\nThe git repository is stored on a Azure [Managed Disk], which is attached to a\nVM.\n\nThe VM is booted once an hour by an Azure Function on a [Timer trigger]. On\nboot, it fetches the latest updates from my mail account and writes them to the\ngit repository. When it's done, it shuts down. This whole process typically\ntakes less than 2 minutes, which means the VM only runs for about 24h in a\nmonth.\n\n[Managed Disk]: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/managed-disks-overview\n[Timer trigger]: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer\n\nThere are three components to this setup stored in this repository:\n\n1. `docker/`: A Docker image containing [OfflineIMAP] and a script to manage the\n   git repo.\n2. `function/`: The source of an Azure Function to periodically boot the VM.\n3. `createvm`: A script which uses the [Azure CLI] to create and configure an\n   appropriate VM. You should create a resource group and managed disk by hand\n   (i.e. through the Azure Portal) before running `createvm`.\n\n[Azure CLI]: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest\n\n## Costs\n\n`createvm` will set up a `Standard_B2s` VM. Running one of these for 24h costs\njust over $1 as of August 2019, so I expect this setup to run about $1/month in\ncompute costs.\n\nAdditional costs apply for the managed data disk and the OS disk. The default OS\ndisk will cost $5.28/mo.\n\n## How to use this\n\nHere's a rough outline of how to adapt this setup for yourself:\n\n1. Create a resource group and a managed disk within that resource group.\n2. Run `createvm`.\n3. Connect to the VM and follow the instructions in `/opt/mailbackup/README`.\n4. Set up an Azure Function App using the code in `function/`.\n5. Enable the system assigned managed identity for the function app (see the\n   \"Identity\" tab) and grant that identity the \"Contributor\" role on the\n   resource group you created in step 1.\n\n   (You may be able to get away with more restrictive permissions -- it needs\n   the ability to list resources in the resource group and start a VM.)\n6. Configure the Function App: you'll need to set the `VM_RESOURCE_GROUP`\n   setting to the name of the resource group in which you created the VM.\n\nNote that you'll certainly need to edit\n`/opt/mailbackup/etc/offlineimaprc.template` and\n`/opt/mailbackup/etc/docker.env` on the VM to suit your needs.\n\n## License\n\nEverything in this repository is shared without warranty under the terms of the\n3-Clause BSD License, a copy of which is provided in `LICENSE`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickstenning%2Fazure-mail-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickstenning%2Fazure-mail-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickstenning%2Fazure-mail-backup/lists"}