@anders94

md in linux isn't really meant to work with detachable devices. It might be easier with lvm instead - a mirror where you remove one of the devices. The real problem you will have is making sense of the filesystem in a disconnected state. It isn't a standard e4fs partition, for example - it even has a different filesystem type ID.

I think you should look at setting up rsync and having a process "live backup" to your USB stick while you have it plugged in. That would be much easier to automate.

@anders94

If you want something that copies everything including the partition table, look at the dd command and bit copy the entire block device:

dd -if /dev/sda -of /dev/yourUSBdevice -bs 4096

but you shouldn't do this on a mounted filesystem because it is almost guaranteed to be in a dirty state. It will work but you will have to repair your disk when starting from the copy.

@anders94

Check out inotifywait as well - that will run something when it notices a change on the filesystem. (in this case you would have it run rsync)

@KrK-EST

I ment to install linux on a 32GB ultrafast usb3 flash drive( 220 to 300 mb/s read speeds).
And i hope to have a copy/sync script that copys all the files from the usb and gives the new drive & partition names to the new location so if i make a backup from the usb sdb2 to sda2, i could boot to the sda2(even if usb would or would not be in port) like it would be the native partition(as it would had been installed on that part.).
Kinda like a working copy of the usbinstallation.

@anders94

Yeah - look at rsync - that should do what you are looking for.

@KrK-EST

some useful stuff, atleast gave few ideas :)

Just one question. I dont want to have constant syncronation, i want to have on demand sync, so i'll have a 230mb/s read speed usb3 stick, and can use it on any pc anywhere, and when on a home pc when booted into the usb i could sync it to my computers hdd, so if i lost the usb flash drive i wont lose all.. and the other way around (using as the main boot the usb, and if i dont have the usb i can have a grub entry for the synced one on hdd)

@KrK-EST

Looks like it's a big help but i still have to figure out and test will it work.
rsync commands would be only 1/3 of the script..