Backup Dữ Liệu Trên Windows Với Restic
1. Cài đặt Restic trên windows
Để cài đặt được Restic trên windows cần phải cài scoop
Mở Windows Powershell
Chạy lệnh trên Powershell
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Chọn Y
Chạy tiếp lệnh
irm get.scoop.sh | iex
Kiểm tra xem scoop đã cài xong chưa
Gõ lên scoop
PS C:UsersTai Cao> scoop Usage: scoop <command> [<args>]
Available commands are listed below.
Type ‘scoop help <command>’ to get more help for a specific command.
Command Summary
——- ——-
alias Manage scoop aliases
bucket Manage Scoop buckets
cache Show or clear the download cache
cat Show content of specified manifest. If available, `bat` will be used to pretty-print the JSON.
checkup Check for potential problems
cleanup Cleanup apps by removing old versions
config Get or set configuration values
create Create a custom app manifest
depends List dependencies for an app, in the order they’ll be installed
download Download apps in the cache folder and verify hashes
export Exports installed apps, buckets (and optionally configs) in JSON format
help Show help for a command
hold Hold an app to disable updates
home Opens the app homepage
import Imports apps, buckets and configs from a Scoopfile in JSON format
info Display information about an app
install Install apps
list List installed apps
prefix Returns the path to the specified app
reset Reset an app to resolve conflicts
search Search available apps
shim Manipulate Scoop shims
status Show status and check for new app versions
unhold Unhold an app to enable updates
uninstall Uninstall an app
update Update apps, or Scoop itself
virustotal Look for app’s hash or url on virustotal.com
which Locate a shim/executable (similar to ‘which’ on Linux)
Cài đặt Restic
Gõ lệnh
scoop install restic
Kiểm tra xem Restic đã cài đặt thành công hay chưa
Gõ lệnh
restic -h
PS C:UsersTai Cao>restic -h
restic is a backup program which allows saving multiple revisions of files and
directories in an encrypted repository stored on different backends.
Usage:
restic [command]
Available Commands:
backup Create a new backup of files and/or directories
cache Operate on local cache directories
cat Print internal objects to stdout
check Check the repository for errors
copy Copy snapshots from one repository to another
diff Show differences between two snapshots
dump Print a backed-up file to stdout
find Find a file, a directory or restic IDs
forget Remove snapshots from the repository
generate Generate manual pages and auto-completion files (bash, fish, zsh)
help Help about any command
init Initialize a new repository
key Manage keys (passwords)
list List objects in the repository
ls List files in a snapshot
migrate Apply migrations
prune Remove unneeded data from the repository
rebuild-index Build a new index
recover Recover data from the repository not referenced by snapshots
restore Extract the data from a snapshot
self-update Update the restic binary
snapshots List all snapshots
stats Scan the repository and show basic statistics
tag Modify tags on snapshots
unlock Remove locks other processes created
version Print version information
Flags:
–cacert file file to load root certificates from (default: use system certificates)
–cache-dir directory set the cache directory. (default: use system default cache directory)
–cleanup-cache auto remove old cache directories
-h, –help help for restic
–insecure-tls skip TLS certificate verification when connecting to the repo (insecure)
–json set output mode to JSON for commands that support it
–key-hint key key ID of key to try decrypting first (default: $RESTIC_KEY_HINT)
–limit-download int limits downloads to a maximum rate in KiB/s. (default: unlimited)
–limit-upload int limits uploads to a maximum rate in KiB/s. (default: unlimited)
–no-cache do not use a local cache
–no-lock do not lock the repository, this allows some operations on read-only repositories
-o, –option key=value set extended option (key=value, can be specified multiple times)
–password-command command shell command to obtain the repository password from (default: $RESTIC_PASSWORD_COMMAND)
-p, –password-file file file to read the repository password from (default: $RESTIC_PASSWORD_FILE)
-q, –quiet do not output comprehensive progress report
-r, –repo repository repository to backup to or restore from (default: $RESTIC_REPOSITORY)
–repository-file file file to read the repository location from (default: $RESTIC_REPOSITORY_FILE)
–tls-client-cert file path to a file containing PEM encoded TLS client certificate and private key
-v, –verbose n be verbose (specify multiple times or a level using –verbose=n, max level/times is 3)
Use “restic [command] –help” for more information about a command.
2. Kết nối Fstorage với Restic
Tạo file credentials trong C:Usersusrname.aws
Nội dung file
[default]
aws_access_key_id = xxxxxxxxxxxxxxxxxxxxxxx
aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3. Các thao tác với Restic
Tạo repository
restic -r s3:https://hcm1.fstorage.vn/multicloud init
Nhập mật khẩu cho repo
Tạo backup
restic -r s3:https://hcm1.fstorage.vn/multicloud backup D:64bit
Kiểm tra Snapshots
restic -r s3:https://hcm1.fstorage.vn/multicloud snapshots
Nhập mật khẩu (mật khẩu vừa tạo lúc init tạo repo)
Restore Snapshots
restic -r s3:https://hcm1.fstorage.vn/multicloud restore 8bf7a3a5 --target D:
(8bf7a3a5 là id snapshots)
Tìm hiểu thêm một số command khách nếu có nhu cầu sử dụng