Forum

Full Version: Command-line version of XBian-copier
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been having issues with the XBian-copier utility, similar to other users (also a bug report of same). Before I directly troubleshoot that, I would like to know if I can invoke the XBian copier from a simple command (or set of commands), like
Code:
xbian-copier /dev/mmcblk0 /path/to/file.img

I was digging around in the xbian-config include files (in /usr/local/include/xbian-config/), but failed to extract something simple from them.

Summary: How can I execute the same function of the XBian-config's XBian copier from the command line?
From the other post, I can invoke the XBian-config utility's xbiancopy function:
Code:
xbian-config xbiancopy start source dest [label] [size]

source: Source partition - normally this is /dev/root (actually booted root), but can by used to copy others as well (btrfs only)
dest: Destination partition - like /dev/sda2 etc. if "dest" is prefixed with "file:", then file will be created
label: By default is "xbian-copy" used
size: (This makes sense only for destination as file.) By default, it is size of source partition, but sometimes, you have 16gb SD card, but 2gb used, so could be specified.

Examples:
Code:
xbian-config xbiancopy start /dev/root /dev/sda1
xbian-config xbiancopy start /dev/root file:/path/to/file.img

Check status with:
Code:
xbian-config xbiancopy status
After I ran this, status immediately returned 0, and I don't know for which status I am looking, but I find it more effective to check the modification time on the file I'm creating:
Code:
ls -l /path/to/file.img
I know it has finished when the last modified time stops increasing.


This method is a start. But, I am wondering which commands this Xbian copier is using to accomplish the copy.
i'm not the developer, but i think it use mk01 script (not really documented):
https://github.com/mk01/btrfs-auto-snapshot

if you want to know deeper, look into the code :-).
I'm pretty sure there is lot more behind the clone function that you believe - dependencies, btrfs copys etc.

You are trying to invoke a command that was never intended, nor tested, to be invoked from the command line, so I'm not surprised you are encountering problems.
(1st Mar, 2014 06:29 AM)IriDium Wrote: [ -> ]You are trying to invoke a command that was never intended, nor tested, to be invoked from the command line, so I'm not surprised you are encountering problems.

I had the problems using the "XBian copier" entry in the XBian-config utility. I'll have to verify more, but the command line seems to have worked better for me.
it should be really the same, as the gui call this command.
if you activate xbmc debug, try Xbian-copier in gui, and look at log, you will find the call "xbian-config xbiancopy start"
Yes we are aware there is an issue with clone in RC1 and it was working in Beta 2.

If it works, then fine
(1st Mar, 2014 06:34 AM)palswim Wrote: [ -> ]
(1st Mar, 2014 06:29 AM)IriDium Wrote: [ -> ]You are trying to invoke a command that was never intended, nor tested, to be invoked from the command line, so I'm not surprised you are encountering problems.

I had the problems using the "XBian copier" entry in the XBian-config utility. I'll have to verify more, but the command line seems to have worked better for me.

@palswim

the middleware is btrfs-auto-snapshot script which uses few different approaches. base idea for cloning btrfs is of course to use the native btrfs send | btrfs recv (it is atomic, copied are data streams not files so it is faster, supports incremental sends (on CoW the data saved since last send).

the img is created as:
1) file is created
2) file is truncated do needed size (size prealocation)
3) in the file 2 partitions are created (/boot and /btrfstop
3a) the parts are mounted via loop devices
4) into /boot /boot is copied and cmdline.txt adapted
5) btrfs send | btrfs recv is used to copy all found subvolumes
6) done

by default size of img is defined as used space reported by df (which unnecessary allocates waste space used by local snapshots which are NOT copied) + 500MB.

this size can be overriden on command line --size

check
Code:
btrfs-auto-snapshot --help

currently I added copying even from ANY filesystem to ANY files-system (via tar | tar -x) but because of formatting of dest partition only ext2/3/4 f2fs nfs is tested and paired with mkfs. this universal copy-to-copy is in /usr/local/include/xbian-config/modules/xbiancopy/main as one function.

btrfs-auto-snapshot is meant as universal snapshot management tool (cross platform). so xbian specifis are kept at xbian-config side, if needed actions resolve to btrfs & snapshots, btrfs-auto-snapshot is called.
Reference URL's