Skip to main content

Storage

Tips#

brew install s3fs
brew install goofys
export AWS_ACCESS_KEY_ID=${ID}export AWS_SECRET_ACCESS_KEY=${KEY}# goofys <bucket> <mountpoint># goofys <bucket:prefix> <mountpoint>
find dir/ -name "offender1" -mtime -1 -print0 | du --files0-from=- -hc | tail -n1

Transfer#

# 两个服务器之间传输大量小文件时非常快# 觉得 gzip 慢可以使用 pigztar c some/dir/ | gzip - | ssh host2 tar xz -C /other/dir/# 全量同步后再进行增量同步rsync -azv some/dir/ [email protected]:/other/dir/

Disk#

#lsblk --output NAME,SIZE,VENDOR,FSTYPE,LABEL,UUID,MODE
# 克隆单个磁盘dd if=/dev/sda1 of=/dev/sdb1 bs=64K conv=noerror,sync status=progress# 克隆整个磁盘dd if=/dev/sdX of=/dev/sdY bs=64K conv=noerror,sync status=progress
# 备份# 备份整个系统rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder# 使用 --info=progress2 显示总体的进度, 而不是每个文件rsync -aAX --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder
# 备份启动分区# https://wiki.archlinux.org/index.php/disk_cloningdd if=/dev/sda1 of=/mnt/dst/bios-boot bs=64K conv=noerror,sync status=progress
# 备份分区sfdisk -d /dev/sda > part_table# 恢复分区sfdisk /dev/sda < part_table# wipefs 也可以