Skip to content

osal.rsync #

to test

echo 'mypasswd' > /tmp/passwd
rsync -avz --password-file=/tmp/passwd /local/path/ rsync://authorizeduser@yourserver/private

fn rsync #

fn rsync(args_ RsyncArgs) !

flexible tool to sync files from to, does even support ssh . args: .

    source string
    dest string
    delete bool //do we want to delete the destination
 ipaddr_src string //e.g. root@192.168.5.5:33 (can be without root@ or :port)
 ipaddr_dst string //can only use src or dst, not both
    ignore []string //arguments to ignore
 ignore_default bool = true //if set will ignore a common set
 stdout bool = true

. see https://github.com/freeflowuniverse/crystallib/blob/development/examples/pathlib.rsync/rsync_example.v

fn rsyncd #

fn rsyncd() !RsyncD

fn usermanager #

fn usermanager() !UserManager

struct RsyncArgs #

@[params]
struct RsyncArgs {
pub mut:
	source         string
	dest           string
	ipaddr_src     string // e.g. root@192.168.5.5:33 (can be without root@ or :port)
	ipaddr_dst     string
	delete         bool     // do we want to delete the destination
	ignore         []string // arguments to ignore e.g. ['*.pyc','*.bak']
	ignore_default bool = true // if set will ignore a common set
	stdout         bool = true
	fast_rsync     bool
}

struct RsyncD #

struct RsyncD {
pub mut:
	configpath  string = '/etc/rsyncd.conf'
	sites       []RsyncSite
	usermanager UserManager
}

fn (RsyncD) site_add #

fn (mut self RsyncD) site_add(args_ RsyncSite) !

add site to the rsyncd config

fn (RsyncD) load #

fn (mut self RsyncD) load() !

get all info from existing config file, populate the sites

fn (RsyncD) generate #

fn (mut self RsyncD) generate() !

struct RsyncSite #

@[params]
struct RsyncSite {
pub mut:
	name     string
	path     string
	comment  string
	readonly bool
	list     bool
	auth     string
	secrets  string
}

struct User #

struct User {
pub mut:
	name   string
	passwd string
}

struct UserArgs #

@[params]
struct UserArgs {
pub mut:
	name   string
	passwd string
}

struct UserManager #

struct UserManager {
pub mut:
	configpath string = '/etc/rsyncd.secrets'
	users      map[string]User
}

fn (UserManager) user_add #

fn (mut self UserManager) user_add(args_ UserArgs) !

fn (UserManager) load #

fn (mut self UserManager) load(args UserArgs) !

fn (UserManager) generate #

fn (mut self UserManager) generate() !

generate the secrets config file