parted /dev/sd${i} -s mklabel gpt parted /dev/sd${i} mkpart primary 0GB 2996GB mkfs.ext3 /dev/sd${i}1
tune2fs -m 0 /dev/sd${i}1
UUID=${UUID} /storage/sd${i}1 ext3 noatime,acl,user_xattr,usrquota 0 0
quotacheck -cu /storage/sd${i}
rpm -Uvh libdb-4_8-4.8.30-18.6.x86_64.rpm rpm -Uvh db-utils-4.8.30-18.6.x86_64.rpm rpm -Uvh netatalk-2.2.4-3.7.x86_64.rpm rpm -Uvh netatalk-devel-2.2.4-3.7.x86_64.rpm
--with-cracklib --with-bdb --enable-tcp-wrappers --enable-zeroconf
~/TimeMachine "BackupMachine" allow:@backupuser cnidscheme:dbd options:usedots,upriv,tm volsizelimit:250000 dbpath:/local/netatalk/db/$u
allow:@backupuser
- allows users who are in the backupuser group to connect;BackupMachine
- the name that will be displayed as a mounted drive physically mounted in ~ / TimeMachine relative to the user;volsizelimit:250000
- will limit the user to a quota of 250 GB, but only if the user is not assigned a system quota. Since in our case, we use system quotas, this option is useless;tm
- a mandatory option, allows TimeMachine on the client side to recognize the allocated resource as valid for the backup;dbpath:/local/netatalk/db/$u
- path to information on user metadata. It is necessary in the case when a list of directories and files that we backed up is built. It will be more practical if it is put on a separate disk, for example, on an SSD;$u
variable substitutes the user name, which we need and does not work in the third version./etc/nettalk/afpd.conf
-setuplog "default log_info /var/log/afpd.log" -keepsessions -transall -savepassword
keepsessions
- saves sessions when you turn off afpd;transall
- includes both protocols - AFP-over-Appletalk and AFP-over-TCP;savepassword
- allows you to remember the user's password in the local keychain (without this option, TimeMachine on Mac OS 10.8 does not work)./etc/netatalk/netatalk.conf
AFPD_MAX_CLIENTS=100
afp://%SERVERNAME%/
/etc/samba/smb.conf
[global] security = user workgroup = Badoo netbios name = BadooBackup local master = no domain master = no preferred master = no socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192 [homes] comment = Home Directories valid users = %S writable = yes create mask = 0700 directory mask = 0700 browseable = No read only = No
| backupusers | CREATE TABLE `backupusers` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `uid` int(11) NOT NULL, `username` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL, `backup_username` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `backup_server` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'backupmsk', `password` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `password_smb` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `shell` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '/bin/false', `map_drive` varchar(6) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'sdc', `quota` int(5) NOT NULL DEFAULT '250', `sftp` tinyint(1) NOT NULL DEFAULT '0', `isactive` tinyint(1) NOT NULL DEFAULT '0', `os` int(1) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
`map_drive`
field is the name of the server and drive that will be used for the current user. It is not set by the administrator; it is automatically distributed depending on the space occupied in this or that section and on the server. If there is not enough space for someone, the data will be transferred to another section;`isactive`
field indicates whether the employee is allowed to use the server for backup. If all OSes are inactive, it will go to the value 0. The user data will not be deleted (useful, for example, if the laptop is lost);`sftp`
field allows the user to use rsync (more on this below). This method will allow “advanced” colleagues to back up their data using self-written scripts. define backupuser_dirs($name,$map_drive,$home="/home/${name}") { file { "$home": owner => $name, ensure => symlink, target => "/storage/${map_drive}/${name}", require => File["/storage/${map_drive}/${name}"]; "/storage/${map_drive}/${name}": owner => $name, ensure => directory, backup => false, mode => 0711; "$home/TimeMachine": owner => $name, ensure => directory, backup => false, mode => 0711, require => File["$home"]; } }
@user { "i.ableev": ensure => $hostname ? { /^%servername%$/ => present, # , default => absent, # , , }, home => "/home/i.ableev", # ; (!) /storage/$map_drive/$name uid => "1217", groups => ['backupuser'], # , password => 'V2UgYXJlIGhpcmluZyEgaHR0cDovL2NvcnAuYmFkb28uY29tL2pvYnMvCg==', # Netatalk rsync shell => "/bin/false", # shell, ssh } @backupuser_dirs { "i.ableev": name => "i.ableev", map_drive =>"sdh", # , /storage/$map_drive/$name require => User["i.ableev"]; } @exec { "i.ableev_quota": command => "/usr/sbin/setquota -u i.ableev 262144000 262144000 0 0 -a", # 250 … path => "/usr/sbin", onlyif => "/usr/bin/test `/usr/sbin/repquota -ua | /usr/bin/egrep '^i.ableev\s*' | /usr/bin/awk {'print \$4'}` -ne \"262144000\"", # … , 250 . } @line { "i.ableev_smb": # /etc/samba/smbpasswd : # @user:$uid:$hash file => '/etc/samba/smbpasswd', line => 'i.ableev:1217:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:5CDA711BBD899465D8F57D12BDF2BF68:[U ]:LCT-5058462B:', # }
define backupuser_dirs_sftp($name,$map_drive,$home) { file { "/home/${name}": owner => $name, ensure => symlink, target => "${home}", require => File["$home"]; "$home": ensure => directory, owner => root, mode => 0755; "$home/sftp": owner => $name, ensure => directory, backup => false, mode => 0711, require => File["$home"]; } } @user { "i.ableev": ensure => $hostname ? { /^backupmsk$/ => present, default => absent, }, home => "/storage/sdh/i.ableev", uid => "1217", groups => ['backupuser'], password => 'V2UgYXJlIGhpcmluZyEgaHR0cDovL2NvcnAuYmFkb28uY29tL2pvYnMvCg==', # shell => "/bin/badooshell", # shell rsync } @backupuser_dirs_sftp { "i.ableev": name => "i.ableev", map_drive =>"sdh", home => "/storage/sdh/i.ableev", # ~/sftp ― require => User["i.ableev"]; } @file { "/storage/sdh/i.ableev/bin": # chroot' ― badooshell ensure => directory, recurse => true, purge => true, force => true, backup => false, owner => root, group => root, source => "puppet:///modules/officebackup/bin/"; # } @file { "/storage/sdh/i.ableev/lib64": # , rsync: ld-linux-x86-64.so.2 libc.so.6 libpopt.so.0 ensure => directory, recurse => true, purge => true, force => true, backup => false, owner => root, group => root, source => "puppet:///modules/officebackup/lib64/"; }
Source: https://habr.com/ru/post/177349/
All Articles