Linux:我如何tar到特定位置?

Linux: how do I tar to a specific location?

我目前正在备份我的系统。如果我使用

> tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found--exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

它说系统没有足够的space。

现在,我已经在目录

挂载了一个U盘
~/mnt/sdc1

我如何 tar backup.tgz 到这个特定位置?

你会想做两件事。首先确保您的驱动器已安装,然后只需提供备份位置的完整路径。例如

mount | grep -q ~/mnt/sdc1       # or just grep -q sdc1 (if it is the only sdc1)
if [ $? -eq 0 ]; then
    tar cvpzf ~/mnt/sdc1/backup.tgz ...
fi

注意:将省略号替换为您的 tar 命令的其余部分。