posts-go/posts/2022-06-08-backup.md

157 lines
6.3 KiB
Markdown
Raw Permalink Normal View History

2021-11-27 15:39:45 +00:00
# Backup my way
2021-11-27 10:54:05 +00:00
2023-08-05 18:56:25 +00:00
First thing first, I want to list my own devices, which I have through the
years:
2021-11-27 10:54:05 +00:00
2023-08-06 10:52:12 +00:00
- ~~Laptop Samsung NP300E4Z-S06VN (old laptop which I give to my mom)~~
2023-08-05 18:56:25 +00:00
- ~~[Laptop Dell Inspiron 15 3567](https://www.dell.com/support/home/en-vn/product-support/product/inspiron-15-3567-laptop/drivers)
2023-08-06 10:52:12 +00:00
[LVFS](https://fwupd.org/lvfs/devices/com.dell.uefi1d4362ca.firmware) (my mom
2023-08-05 18:56:25 +00:00
bought it for me when I go to college, I give it to my mom afterward)~~
- ~~[Laptop Acer Nitro AN515-45](https://www.acer.com/ac/en/US/content/support-product/8841)
2023-08-06 10:52:12 +00:00
(gaming laptop which I buy for gaming, I give it to my sister)~~
- MacBook Pro M1 2020 (my company laptop)
2023-08-05 18:56:25 +00:00
- ~~Phone [LG G3 D851 T-Mobile](https://forum.xda-developers.com/c/lg-g3.3147/)
2023-08-06 10:52:12 +00:00
(bought long time ago, now is a brick)~~
- ~~Phone [Xiaomi Redmi 6A](https://www.gsmarena.com/xiaomi_redmi_6a-9217.php)
(I give it to my sister too)~~
2023-08-05 18:56:25 +00:00
- Phone
2023-08-06 10:52:12 +00:00
[Xiaomi Poco X3 NFC](https://www.gsmarena.com/xiaomi_poco_x3_nfc-10415.php)
(primary phone which I use daily)
2021-11-27 10:54:05 +00:00
App/Service I use daily:
2023-06-10 04:53:34 +00:00
- [Bitwarden](https://bitwarden.com/): password manager
- [Aegis Authenticator](https://getaegis.app/): 2FA manager
- [Rclone](https://rclone.org/): sync data to cloud
- [restic](https://restic.net/): backup data
2021-11-27 10:54:05 +00:00
- [Tailscale](https://tailscale.com/)
2023-08-06 10:52:12 +00:00
- GitHub / GitLab / [SourceHut](https://git.sr.ht/) /
2023-10-05 19:00:00 +00:00
[Codeberg](https://codeberg.org/): stores git repo
2023-08-06 10:52:12 +00:00
- Google Keep / Notion
2023-06-10 04:53:34 +00:00
- Google Drive (currently use 200GB plan)
2023-08-06 10:52:12 +00:00
- GMail / [SimpleLogin](https://simplelogin.io/) / Proton Mail: my mail
2021-11-27 10:54:05 +00:00
2023-08-05 18:56:25 +00:00
The purpose is that I want my data to be safe, secure, and can be easily
recovered if I lost some devices; or in the worst situation, I lost all. Because
you know, it is hard to guess what is waiting for us in the future.
2021-11-27 10:54:05 +00:00
2023-08-06 10:52:12 +00:00
There are 2 main sections which I want to share, the first is **How to backup**,
the second is **Recovery strategy**.
2021-11-27 10:54:05 +00:00
## How to backup
2023-08-05 18:56:25 +00:00
Before I talk about backup, I want to talk about data. In specifically, which
data should I backup?
I use Arch Linux and macOS, primarily work in the terminal so I have too many
dotfiles, for example, `~/.config/nvim/init.lua`. Each time I reinstall Arch
Linux (I like it a lot), I need to reconfigure all the settings, and it is
time-consuming.
So for the DE and UI settings, I keep it as default as possible, unless it's
getting in my way, I leave the default setting there and forget about it. The
others are dotfiles, which I write my own
[dotfiles tool](https://github.com/haunt98/dotfiles) to backup and reconfigure
easily and quickly. Also, I know that installing Arch Linux is not easy, despite
2023-08-06 10:52:12 +00:00
I install it too many times (like thousand times since I was in high school).
2023-08-05 18:56:25 +00:00
Not because it is hard, but as life goes on, the
[official install guide](https://wiki.archlinux.org/title/installation_guide)
keeps getting new update and covering too many cases for my own personal use, so
I write my own
2023-08-06 10:52:12 +00:00
[guide](https://github.com/haunt98/posts-go/blob/main/posts/2022-12-25-archlinux.md)
to quickly capture what I need to do.
2023-08-05 18:56:25 +00:00
So that is my dotfiles, for my regular data, like Wallpaper or Books, Images, I
2023-08-06 10:52:12 +00:00
use Google Drive (actually I pay for it). But the step: open the webpage, click
2023-08-05 18:56:25 +00:00
the upload button and choose files seems boring and time-consuming. So I use
Rclone, it supports Google Drive, One Drive and many providers but I only use
Google Drive for now. The commands are simple:
2021-11-27 10:54:05 +00:00
```sh
# Sync from local to remote
2023-07-30 09:37:36 +00:00
# remote can be gdrive, 1drive, ..., anything you previously config with rclone
2021-12-18 11:30:09 +00:00
rclone sync MyBooks remote:MyBooks -P --exclude .DS_Store
2021-11-27 10:54:05 +00:00
# Sync from remote to local
2021-12-18 11:30:09 +00:00
rclone sync remote:MyBooks MyBooks -P --exclude .DS_Store
2021-11-27 10:54:05 +00:00
```
2023-08-05 18:56:25 +00:00
Before you use Rclone to sync to Google Drive, you should read
[Google Drive rclone configuration](https://rclone.org/drive/) first.
2021-11-27 10:54:05 +00:00
2023-06-10 04:53:34 +00:00
For private data, I use restic which use Rclone as backend:
2022-09-07 14:13:47 +00:00
```sh
# Init
restic -r rclone:remote:PrivateData init
# Backup
restic -r rclone:remote:PrivateData backup PrivateData
2022-11-21 07:13:27 +00:00
# Cleanup old backups
restic -r rclone:remote:PrivateData forget --keep-last 1 --prune
2022-12-03 07:43:46 +00:00
# Restore
2023-07-30 09:37:36 +00:00
# Be careful because restic restore fullpath
# See https://github.com/restic/restic/issues/2092
2022-12-03 07:43:46 +00:00
restic -r rclone:remote:PrivateData restore latest --target ~
2022-09-07 14:13:47 +00:00
```
2023-08-05 18:56:25 +00:00
The next data is my passwords and my OTPs. These are the things which I'm scare
to lose the most. First thing first, I enable 2-Step Verification for all of my
important accounts, should use both OTP and phone method.
2021-11-27 10:54:05 +00:00
2023-08-06 10:52:12 +00:00
I use Bitwarden for passwords (that is a long story, coming from Google Password
2023-08-05 18:56:25 +00:00
manager to Firefox Lockwise and then settle down with Bitwarden) and Aegis for
OTPs. The reason I choose Aegis, not Authy (I use Authy for so long but Aegis is
definitely better) is because Aegis allows me to extract all the OTPs to a
2023-08-06 10:52:12 +00:00
single file (can be encrypted), which I use to transfer or backup easily.
2021-11-27 10:54:05 +00:00
2023-08-05 18:56:25 +00:00
As long as Bitwarden provides free passwords stored, I use all of its apps,
extensions so that I can easily sync passwords between laptops and phones. The
thing I need to remember is the master password of Bitwarden in my head.
2021-11-27 10:54:05 +00:00
2023-08-06 10:52:12 +00:00
With Bitwardent/Aegis, I also can export the data (must always be encrypted),
then:
2023-08-06 10:52:12 +00:00
- Sync to Google Drive
- Store locally in my laptop
- Don't store locally in phone (can not keep track easily)
2021-11-27 10:54:05 +00:00
2023-06-30 15:54:50 +00:00
### Backup work related data
APIs tools:
- [HTTPie](https://httpie.io/app)
- Already sync online (for now).
2023-08-05 18:56:25 +00:00
Stay away from Postman, it's lag and you can accidentally upload private data
publicly.
2023-06-30 15:54:50 +00:00
2021-11-27 10:54:05 +00:00
## Recovery strategy
2023-08-05 18:56:25 +00:00
There are many strategies that I process to react as if something strange is
happening to my devices.
2021-11-27 10:54:05 +00:00
2023-08-05 18:56:25 +00:00
- If I lost my laptops, single laptop or all, do not panic as long as I have my
phones. The OTPs are in there, the passwords are in Bitwarden cloud, other
data is in Google Drive so nothing is lost here.
- If I lost my phone, but not my laptops, I use the OTPs which are stored
locally in my laptops.
- In the worst situation, I lost everything, my laptops, my phone. The first
step is to recover my SIM, then log in to Google account using the password
and SMS OTP. After that, log in to Bitwarden account using the master password
2023-08-06 10:52:12 +00:00
and OTP from Gmail, which I log in previously.
2021-11-27 15:39:45 +00:00
2023-06-10 04:53:34 +00:00
## Misc
2023-08-05 18:56:25 +00:00
To backup everything is hard, so keep it simple and only backup important
things. Pick one then stay away from other cloud services:
2023-06-10 04:53:34 +00:00
2023-08-06 10:52:12 +00:00
- TODOis, Evernote, ... -> Google Keep / Notion
2023-06-10 04:53:34 +00:00
- Dropbox, OneDrive, ... -> Google Drive
2021-11-27 15:39:45 +00:00
## The end
This guide will be updated regularly I promise.