shell-host/modules/copyrootfs.func

36 lines
574 B
Bash

#!/bin/bash
module_load filesystem
module_load confirm
copy_rootfs () {
local dr=""
# local de=--delete-excluded
[[ ! $(mounted $1) ]] && echo $1 is not a mountpoint exiting && return 2
cmd=$(echo sudo rsync $dr $de --progress -aAXv --exclude={\
"/dev/*",\
"/proc/*",\
"/sys/*",\
"tmp/*",\
"/run/*",\
"/mnt/*",\
"/media/*",\
"/lost+found",\
"/data/*",\
"/backup/*",\
"/snapshots/*",\
"/remotes/*",\
"*[Cc]ache*",\
"*/[Ll]og/*",\
"*/[Ll]ogs/*",\
"*.[Ll]og",\
"/etc/fstab*",\
"/boot/refind_linux.conf"\
}\
/ $1
)
echo $cmd
if confirm run this copy command; then
$cmd
fi
}