[英]How to do a backup of files using the terminal?
I've already done a backup of my database, using mysqldump like this: 我已经使用mysqldump这样完成了数据库备份:
mysqldump -h localhost -u dbUsername -p dbDatabase > backup.sql
After that the file is in a location outside public access, in my server, ready for download. 之后,该文件位于公共访问权限之外的位置,即在我的服务器中,可供下载。
How may I do something like that for files? 我该如何处理文件? I've tried to google it, but I get all kind of results, but that.
我试图用谷歌搜索它,但是我得到了各种各样的结果,但是那样。
I need to tell the server running ubuntu to backup all files inside folder X, and put them into a zip file. 我需要告诉运行ubuntu的服务器备份文件夹X中的所有文件,并将它们放入zip文件中。
Thanks for your help. 谢谢你的帮助。
You can use tar for creating backups for a full system backup 您可以使用tar创建完整系统备份的备份
tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz /
for a single folder 对于单个文件夹
tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz /your/folder
to create a gzipped tar file of your whole system. 创建整个系统的压缩tar文件。 You might need additional excludes like
--exclude=/proc --exclude=/sys --exclude=/dev/pts
. 您可能需要其他排除对象,例如
--exclude=/proc --exclude=/sys --exclude=/dev/pts
。
If you are outside of the single folder you want to backup the --exclude=/backup.tar.gz
isn't needed. 如果您不在单个文件夹中,
--exclude=/backup.tar.gz
备份--exclude=/backup.tar.gz
。
More details for example here (you can do it over network, split the archive etc.). 例如, 此处有更多详细信息(您可以通过网络进行操作,拆分存档等)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.