fre*_*red 12 windows linux backup bash
我正在为我的个人桌面从 Windows 迁移到 Ubuntu,我想知道一种简单的方法来备份个人数据,例如 Firefox 书签、个人文档等...
在 Windows 中,我手动复制所有内容,而在 Ubuntu 中,我想创建一个 bash 脚本来自动完成。
除了创建文件并使其可执行之外,我对 bash 脚本一无所知,还有这个简单的例子:
#!/bin/bash
cp /files/file.doc /media/flashdrive/
Run Code Online (Sandbox Code Playgroud)
如何自动检测我当前的个人资料?(我的电脑上目前有 3 个配置文件,一个我不使用,一个给我的没有书签的妻子,还有我的)。
Boo*_*eus 18
我建议使用rsync(在 Ubuntu 中)。
如果您有数百兆的数据,您可能只想同步/备份修改后的数据。这将提高备份速度。
对于主机等其他文件,您可以简单地 cp
现在对于 firefox,您需要找到您正在使用的配置文件,profiles.ini
然后您可以复制 bookmarks.html
您可以使用 grep 找出profiles.ini 使用的文件夹:
grep Path ~/.mozilla/firefox/profiles.ini
Run Code Online (Sandbox Code Playgroud)
这将输出:
Path=e8tog617.default
Run Code Online (Sandbox Code Playgroud)
然后取出 Path=
sed "s/Path=//g"
Run Code Online (Sandbox Code Playgroud)
这是 backup.sh 的样子:
rsync -rltDqv ~/Documents/ /media/flashdrive/Documents/
cp ~/.mozilla/firefox/`grep Path ~/.mozilla/firefox/profiles.ini | sed "s/Path=//g"`/bookmarks.html /media/flashdrive/bookmarks.html
cp /etc/hosts /media/flashdrive/hosts
Run Code Online (Sandbox Code Playgroud)
现在,chmod +x
你的backup.sh 然后运行它./backup