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
daemon_mode bool // use rsync daemon protocol instead of SSH
daemon_port int // port for rsync daemon
daemon_user string // username for rsync daemon auth
daemon_host string // host/IP for rsync daemon
daemon_module string // rsync module path
password string // password for rsync daemon auth
. see https://github.com/incubaid/herolib/blob/development/examples/pathlib.rsync/rsync_example.v
fn rsync_daemon #
fn rsync_daemon(args RsyncArgs) !
rsync_daemon performs rsync using the rsync daemon protocol with password authentication. This is used for syncing to remote rsync daemons (not SSH-based). The password is written to a temporary file which is cleaned up after the operation.
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
fast_rsync bool
sshkey string
// rsync daemon mode options (alternative to SSH)
daemon_mode bool // if true, use rsync daemon protocol instead of SSH
daemon_port int // port for rsync daemon (e.g., 30873)
daemon_user string // username for rsync daemon auth (e.g., 'atlas')
daemon_host string // host/IP for rsync daemon (e.g., '51.195.61.5')
daemon_module string // rsync module path (e.g., 'sites/info')
password string // password for rsync daemon auth
}
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