{"id":18045258,"url":"https://github.com/dpb587/timepolicy","last_synced_at":"2025-04-05T03:41:43.951Z","repository":{"id":230162246,"uuid":"638030474","full_name":"dpb587/timepolicy","owner":"dpb587","description":"Implement retention policies on the command line across a variety of object and storage types.","archived":false,"fork":false,"pushed_at":"2023-05-09T02:28:01.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T11:48:27.251Z","etag":null,"topics":["backup-utility","cli","expiration","golang","policies","retention","time","unix"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dpb587.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}},"created_at":"2023-05-09T00:04:25.000Z","updated_at":"2023-05-09T02:29:24.000Z","dependencies_parsed_at":"2024-03-28T06:29:58.892Z","dependency_job_id":"10734850-810d-468b-af13-f32d07cafb54","html_url":"https://github.com/dpb587/timepolicy","commit_stats":null,"previous_names":["dpb587/timepolicy"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpb587%2Ftimepolicy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpb587%2Ftimepolicy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpb587%2Ftimepolicy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dpb587%2Ftimepolicy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dpb587","download_url":"https://codeload.github.com/dpb587/timepolicy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284914,"owners_count":20913691,"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":["backup-utility","cli","expiration","golang","policies","retention","time","unix"],"created_at":"2024-10-30T18:12:39.950Z","updated_at":"2025-04-05T03:41:43.933Z","avatar_url":"https://github.com/dpb587.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# timepolicy\n\nImplement retention policies on the command line across a variety of object and storage types.\n\n## Command Line Usage\n\nPipe lines that start with a time and configure `--policy` specifications to control which line entries match.\n\n```shell\n( echo '2023-01-01 backup-20230101.tar.gz' ; echo '2023-01-02 backup-20230102.tar.gz' ) \\\n  | go run ./cmd/timepolicy \\\n    --policy='1y;by=month' \\\n    --time=YYYY-MM-DD \\\n    --write='$2'\n#\u003e backup-20230102.tar.gz\n```\n\nSee [`timepolicy --help`](https://github.com/dpb587/timepolicy/blob/resources/release/latest/timepolicy-help.txt) for full documentation and features.\n\n### Installation\n\nBinaries for Linux, macOS, and Windows can be downloaded from the [Releases](https://github.com/dpb587/timepolicy/releases/latest) page. A [Homebrew](https://brew.sh/) recipe is also available for Linux and macOS.\n\n```\nbrew install dpb587/tap/timepolicy\n```\n\n### Examples\n\nPrune Google Cloud snapshots based on creation time...\n\n```shell\ngcloud compute snapshots list --format='value(creationTimestamp, name)' \\\n  | timepolicy \\\n      --policy='1y;by=month // within 1 year, keep newest per month' \\\n      --policy='28d;by=day  // within 28 days, keep newest per day' \\\n      --policy='7d;by=hour  // within 7 days, keep newest per hour' \\\n      --write='$2' \\\n      --invert \\\n  | xargs -- \\\n      echo gcloud compute snapshots delete\n```\n\nPrune local backup files based on date in file name (e.g. `Hubitat_2023-05-04~2.3.5.131.lzf`)...\n\n```shell\nfind . -name '*.lzf' \\\n  | sed -E 's#./(Hubitat_(..........).+)#\\2 \\1#' \\\n  | timepolicy \\\n      --policy='1y;by=month // within 1 year, keep newest by month' \\\n      --policy='14d;by=day  // within 14 days, keep newest by day' \\\n      --ts='YYYY-MM-DD' \\\n      --write='$2' \\\n      --invert \\\n  | xargs -n1 -- \\\n      echo rm\n```\n\nList selected files from Amazon S3 and total size based on modification date...\n\n```shell\naws s3api list-objects --bucket acme-backup-us-west-1 \\\n  --output=text \\\n  --query='Contents[*].[LastModified, Size, Key]' \\\n  | timepolicy \\\n      --policy='14d;by=day;oldest // within 14 days, keep oldest by day' \\\n  | tee \u003e( cut -f3 ) \\\n  | cut -f2 | paste -sd+ - | bc | numfmt --to=iec-i\n```\n\n## Futures\n\n* support reading policies from files\n* expand unit tests\n\n## License\n\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpb587%2Ftimepolicy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdpb587%2Ftimepolicy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdpb587%2Ftimepolicy/lists"}