Skip to content

Latest commit

 

History

History
135 lines (90 loc) · 3.75 KB

README.en_US.md

File metadata and controls

135 lines (90 loc) · 3.75 KB

@wuxh/backup-cli

Backup your configuration files and directories Why?, lra/mackup#1969.

npm npm

简体中文 | English

Installation

npm i @wuxh/backup-cli -g

Usage

Backup

backup-cli

Restore

backup-cli -r

Support Apps

backup-cli -l

View Configuration

backup-cli -c

CLI Options

Use backup-cli -h to see the latest usage instructions:

    npx @wuxh/backup-cli [options]
    ----------------------------------------
    -l, --list: list all apps.
    -f, --force: force to backup (overwrite files).
    -c, --config: view config.
    -r, --restore: restore backup.
    -h, --help: show help.
    -d, --debug: show debug info.
    -v, --version: show version. vx.x.x
    ----------------------------------------
    e.g. backup-cli -h

Config

By default, $HOME/.backuprc is used as the configuration file, and you can also customize other locations by setting the BACKUP_CONFIG_FILE environment variable.

[storage]
; Backup path, default: current directory where the command is executed.
path = $PWD
; Backup directory, default: backup
directory = backup

; Synchronized applications, default: synchronize all
[applications_to_sync]
zsh

; Ignore a certain application, default: empty
[applications_to_ignore]
git

Custom Application

Define the [application name].cfg configuration file and place it in the $HOME/.backup directory. You can customize other directories by setting the BACKUP_CUSTOM_APP_DIR environment variable.

[application]
name = Git

; Directories or files to be synchronized, concatenated from $HOME
[configuration_files]
.gitconfig_work

; XDG configuration file, concatenated from $XDG_CONFIG_HOME
; see: https://specifications.freedesktop.org/basedir-spec/latest
[xdg_configuration_files]
git/config

Advanced

Forced Restore

When using backup-cli -r to restore backups, the --force option does not bypass confirmation prompts even when set to force overwriting files. This is due to security and data integrity considerations; by default, backups are not overwritten without user consent.

  • Tip: You can enforce a restore operation by setting the environment variable BACKUP_FORCE_RESTORE = true. However, it's important to note that this still requires using the --force argument in your command.

Restoring Another's Backup

When attempting to restore files from backup directories into your $HOME directory, the issue might arise because their $HOME directories may differ from yours. Direct restoration would fail due to these differences.

  • Tip: To successfully restore another person's backups, you can set the environment variable BACKUP_UPSTREAM_HOME={theirs HOME directory} in your command. This specifies where each file should be placed upon restoration, ensuring they are correctly located on your system.

Who is Using

Contribution

  1. Clone the project and install dependencies using pnpm
git clone [email protected]:Wxh16144/backup-cli.git && cd backup-cli \
    && pnpm install

You can then press F5 in VSCode to start the debugger, launch.json

LICENSE

MIT

Reference