sh 从Linux桌面备份和还原个人文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 从Linux桌面备份和还原个人文件相关的知识,希望对你有一定的参考价值。
#!/bin/bash
echo -n "Starting backup... Are you sure ? y/(n) " ; read response
test ${response:-n} != "y" && exit 1
dotfiles=$(dirname $0)/dotfiles.txt
destination=$(dirname $0)/home
# create dotfiles archives or append new files to it
tar -czf $HOME/dotfiles.tar.gz -C $HOME --files-from=$dotfiles
rsync -av $HOME/dotfiles.tar.gz "$destination"
# retrieve all visible directories and dotfiles archives
dir_options="-mindepth 1 -maxdepth 1 -type d"
while IFS= read -r -d '' directory ; do
(
# ignore git subfolders
find $directory -type d -name .git -exec dirname {} \; | sed -e "s;$HOME/;;" -e 's;$;/*;'
# ignore large files
find $directory -type f -size +200M | sed -e "s;$HOME/;;"
) > $HOME/.exclude
test -s $HOME/.exclude && excludefrom="--exclude-from=$HOME/.exclude"
rsync $excludefrom -av "$directory" "$destination"
unset excludefrom
done < <(find $HOME $dir_options -name "[^.]*" -print0)
echo -n "Backup done. Press a key..." ; read
#! /bin/bash
### Restore commands
cd /run/media/$(whoami)/*
tar -xf home/dotfiles.tar.gz -C $HOME
rsync --exclude=dotfiles.tar.gz -av home/ $HOME
chown -R $(whoami): $HOME
### Software install
# sudo pacman -Syu
# sudo pacman -Sy firefox thunderbird keepassxc autorandr libvirt virt-manager
# pamac build dino spotify-dev
以上是关于sh 从Linux桌面备份和还原个人文件的主要内容,如果未能解决你的问题,请参考以下文章
sh 从备份中简单还原cms db
Linux系统备份还原工具2(TAR/压缩工具)
备份和还原邮件
sh 备份和还原数据库
sh 备份和还原Gmail
sh 备份和还原Magicpref设置