{"id":26295988,"url":"https://github.com/zuf/watch-and-bak","last_synced_at":"2025-07-19T08:08:24.839Z","repository":{"id":65071349,"uuid":"581680940","full_name":"zuf/watch-and-bak","owner":"zuf","description":"Very simple backup tool. Watches for given file and make backups (.gz) in separate dir after that file was changed.","archived":false,"fork":false,"pushed_at":"2023-01-21T14:57:22.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T04:16:10.605Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zuf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-23T23:43:36.000Z","updated_at":"2022-12-23T23:54:55.000Z","dependencies_parsed_at":"2023-02-12T10:47:03.741Z","dependency_job_id":null,"html_url":"https://github.com/zuf/watch-and-bak","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zuf/watch-and-bak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuf%2Fwatch-and-bak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuf%2Fwatch-and-bak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuf%2Fwatch-and-bak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuf%2Fwatch-and-bak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zuf","download_url":"https://codeload.github.com/zuf/watch-and-bak/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuf%2Fwatch-and-bak/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265904328,"owners_count":23846674,"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":"2025-03-15T04:16:13.189Z","updated_at":"2025-07-19T08:08:24.811Z","avatar_url":"https://github.com/zuf.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# watch-and-bak\n\nVery simple backup tool.\nWatches for given file and make backups (.gz) in separate dir after that file was changed.\n\n## Install\n\n```\n$ go install github.com/zuf/watch-and-bak@latest\n```\n\n\n## Usage\n\n```\n$ watch-and-bak --help\n\nUsage:\n  watch-and-bak [OPTIONS] /path/to/file [/path/to/another/file] ...\n\n  -d string\n    \tSpecify backup directory (default \"./bak\")\n  -n duration\n    \tSpecify polling interval. A duration string is a sequence of decimal\n    \tnumbers, each with optional fraction and a unit suffix, such as \"1m30s\"\n    \tor \"-1.5h\". Valid time units are \"s\", \"m\", \"h\" (default 1m0s)\n  -p string\n    \tSpecify backup file prefix\n    \tFormat explanation:\t\n    \t  Year: \"2006\" \"06\"\n    \t  Month: \"Jan\" \"January\" \"01\" \"1\"\n    \t  Day of the week: \"Mon\" \"Monday\"\n    \t  Day of the month: \"2\" \"_2\" \"02\"\n    \t  Day of the year: \"__2\" \"002\"\n    \t  Hour: \"15\" \"3\" \"03\" (PM or AM)\n    \t  Minute: \"4\" \"04\"\n    \t  Second: \"5\" \"05\"\n    \t  AM/PM mark: \"PM\"\n    \t\n    \t (default \"20060102_150405_\")\n  -z int\n    \tSpecify gzip compression level. Values from 1 to 9. (default 9)\n\n```\n\n\n## Alternative (on linux)\n\nDo not want use weird software from internet?\n\nUse plain old bash like that (you need to install `inotify-tools`):\n\n\n```bash\n#!/bin/bash\n\nset -e\n\n# Sleep and skip all changes in files for that period (seconds)\n# after every backup operation (to not create backups too often).\nSLEEP_PERIOD=60\nBASE_BAK_DIR='./bak/'\n\nwhile true;\ndo\n\tFILE=$(inotifywait -e modify $@ | awk '{print $1}')\t\n\tBASENAME=$(basename \"${FILE}\")\n\tBAK_PREFIX=$(date +%Y%m%d_%H%M%S_)\n\tFILE_BAK_DIR=\"${BASE_BAK_DIR}/$(date +%Y-%m-%d)/\"\t\n\tFULL_BAK_PATH=\"${FILE_BAK_DIR}/${BAK_PREFIX}${BASENAME}.gz\"\n\t\n\tmkdir -p \"${FILE_BAK_DIR}\"\n\tcat \"$FILE\" | gzip -9 \u003e \"${FULL_BAK_PATH}\"\n\t\n\techo \"File ${BASENAME} saved to ${FULL_BAK_PATH}\" \u003e /dev/stderr\n\t\n\tsleep $SLEEP_PERIOD\ndone\n```\n\nUsage:\n\n\n```\n$ ./watch-and-bak.sh /path/to/your/files...\n```\n\nThis script just an example, adapt for your needs.\n\n[watch-and-bak.sh](watch-and-bak.sh)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuf%2Fwatch-and-bak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuf%2Fwatch-and-bak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuf%2Fwatch-and-bak/lists"}