{"id":19144042,"url":"https://github.com/sourlemonjuice/backup-linux-dir-script","last_synced_at":"2026-04-30T12:32:58.046Z","repository":{"id":211617058,"uuid":"715905930","full_name":"SourLemonJuice/backup-linux-dir-script","owner":"SourLemonJuice","description":"backup and restore linux folder with tar by bash script | 用 bash 脚本和 tar 备份与恢复 Linux 文件夹","archived":false,"fork":false,"pushed_at":"2023-12-09T18:25:54.000Z","size":98,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T19:31:22.139Z","etag":null,"topics":["backup-script","bash","chinese-simplified","folder","linux","shell-script","tar"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/SourLemonJuice.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,"governance":null}},"created_at":"2023-11-08T04:15:56.000Z","updated_at":"2024-08-19T15:30:59.000Z","dependencies_parsed_at":"2023-12-09T18:44:56.940Z","dependency_job_id":null,"html_url":"https://github.com/SourLemonJuice/backup-linux-dir-script","commit_stats":null,"previous_names":["sourlemonjuice/backup-linux-dir-script"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/SourLemonJuice/backup-linux-dir-script","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2Fbackup-linux-dir-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2Fbackup-linux-dir-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2Fbackup-linux-dir-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2Fbackup-linux-dir-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SourLemonJuice","download_url":"https://codeload.github.com/SourLemonJuice/backup-linux-dir-script/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SourLemonJuice%2Fbackup-linux-dir-script/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32465009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-script","bash","chinese-simplified","folder","linux","shell-script","tar"],"created_at":"2024-11-09T07:33:24.746Z","updated_at":"2026-04-30T12:32:58.033Z","avatar_url":"https://github.com/SourLemonJuice.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bash 文件夹备份脚本\n\n这算是一个学习用的脚本了，各种地方写得都应该很差吧，咕咕\n\n## 能干什么\n\n一个（一堆）备份目录到tar文件，并且能按顺序恢复的脚本\\\n支持tar的增量备份模式（不会记录删除有什么用呢）\n\n---\n\n## 使用\n\n运行 `src/main.sh`，默认显示帮助信息(--help)\\\n用`-h | --help`查看帮助信息\n\n虽然脚本文件很多但主脚本中有检测文件本身路径的逻辑，不用担心不在脚本根目录执行会无法加载其他函数的问题\n\n### 备份\n\n在备份文件夹内会**再有一层文件夹**用来支持增量备份\\\n使用`-B`会自动检测是否有以前的备份组可用，如果没有(比如第一次使用)就会触发完全备份模式\\\n使用`--full-backup`参数会强制在新的文件夹里创建一个完整备份\n\n\u003e 完全备份模式也使用了`-g`参数，但放置备份的文件夹是全新的\\\n\u003e 使用`--one-file-system`参数，不会打包正常根目录里的`dev`这类文件夹\n\n```text\n.\n├── 1700956381_2023-11-26_07-53-01\n│   ├── 1700956384_2023-11-26_07-53-04_backup.tar\n│   ├── .log\n│   └── .tar_snapshot\n├── 1700956534_2023-11-26_07-55-34\n│   ├── 1700956535_2023-11-26_07-55-35_backup.tar\n│   ├── 1700956584_2023-11-26_07-56-24_backup.tar\n│   ├── .log\n│   └── .tar_snapshot\n└── .now_backup\n```\n\n\u003e 这里的`.log`不是脚本日志，是记录顺序的文件，日志位置和名称写在配置里\n\n```text\n-B,--backup \u003c压缩选项\u003e 创建备份\n   --full-backup \u003c压缩选项\u003e 强制创建新的完全备份\n```\n\n### 恢复\n\n从某个备份组按顺序释放文件\n\n```text\n-R,--restore \u003c索引方式\u003e 选择备份文件恢复\n```\n\n---\n\n## 配置\n\n将需要修改的文件放入`src/config.d`文件夹就能生效（使用bash赋值语法）\n\n\u003e `0a.`开头的是默认配置，最好写一个新的\\\n\u003e 文件夹内的配置文件会按照 `名称` `顺序` 加载和覆盖\n\n### 强制使用root权限\n\n可以在执行脚本前检查是否为root权限\n\n```shell\n# general\nNeedRoot=1\n```\n\n### 备份路径\n\n`BackupFolder`是要存放备份文件的根路径\\\n`RootPath`是要备份的目录\n\n\u003e 所有目录都可以使用相对路径（相对于那堆脚本文件）\n\n```shell\n# path\nBackupFolder=/usr/sys_backup\nRootPath=/\n```\n\n### tar增量备份\n\n强制每次备份使用完整备份\\\n开启=不使用tar增量备份模式（-g 参数）\n\n```shell\n# general\nTar_Default_Full_Backup=1\n```\n\n### 日志目录\n\n设置日志存放的目录\n\n```shell\n# log\nLogPath=./log\nLogName=running.log\n```\n\n## 怪问题们\n\n- 为什么不把东西都放到一起呀，这样多乱\n  - 那就彻底看不懂了啊w\n  - 还有...懒，反正有配置文件在两个文件和一堆文件也没什么区别嘛\n- 为什么注释用中文，各种变量名用英文还写得稀烂\n  - 因为不会英语所以要练嘛，那既然不会注释还写英文那我还写它干什么\n- 就是压缩解压一下怎么写了这么一大坨东西出来\n  - 最开始是想写一个类似于定期备份系统的脚本，弄了半天才发现tar没法记录文件的删除，但已经写了按顺序解压的逻辑了就顺便把其他的东西完善一下，反正也是在学东西嘛\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourlemonjuice%2Fbackup-linux-dir-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourlemonjuice%2Fbackup-linux-dir-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourlemonjuice%2Fbackup-linux-dir-script/lists"}