+
    4Ssi¿ß  ã                   ó8  € ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t
 ^ RIHtHt ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHt ^ RIHt ^ RIHtHtHt ^ R	IH t  ^ R
I!H"t"H#t# ^ RI$H%t%H&t&H't' ^ RIH(t( ^ RI)H*t* ^ RI+H,t,H-t- ^ RI.H/t/ ^ RI0H1t1 ^ RI+H2t2 ^ RI3H4t4 ^ RI5t5^ RI+H6t6H7t7H8t8 ^ RI9H:t:H;t;H<t< ^ RI=H>t> ^ RI?H@t@ ^ RIAtA^ RIBHCtC ^ RIHDtD ^ RIEHFtF ^ RIGHHtH ^ RIIHJtJ ^ RIHKtL ^ RIMtMR tNR tOR tPR  tQR! tRR" tSR1R# ltTR$ tUR% tVR& tW ! R' R(]P°                  P²                  4      tZ ! R) R*]*4      t[ ! R+ R,]P°                  P²                  4      t\ ! R- R.]P°                  P²                  4      t] ! R/ R0]P°                  P¼                  4      t_R# )2é    N)ÚSamDBÚget_default_backend_store)ÚLdbError)Úlibsmb_samba_internal)Úparam)Úbackup_onlineÚbackup_restoreÚbackup_offline)Úsystem_session)ÚDCJoinContextÚ
join_cloneÚDCCloneAndRenameContext)Údom_sid)ÚOptionÚCommandError)ÚmiscÚsecurityÚdrsblobs)ÚLdb)Úcmd_fsmo_seize)Úmake_smbconfÚDEFAULTSITE)Úupdate_krbtgt_account_password)Ú	remove_dc)Úsecretsdb_self_join)Údbcheck)Úguess_namesÚdetermine_host_ipÚdetermine_host_ip6)Úfill_dns_data_partitionsÚget_dnsadmins_sidÚget_domainguid)Útdb_copy)Úmdb_copy)ÚCalledProcessError)Úsites)Ú_dsdb_load_udv_v2)Úndr_pack)ÚSMB_SIGNING_REQUIRED)Úsafe_tarfilec                 óÔ  €  V P                  4       p\	        T P                  4       4      p\        T4      R,           \        T4      ,           p T P                  \        P                  RT,          . RR.R7      p\        T4      ^8w  d   \        R	T,          4      h\        R
T: RT^ ,          P                  : R24      h  \         d4   pTP                  R 4       TP                  R4       \        RT4      hRp?ii ; i  \        P                   d/   pTP                  w  r‰T\        P                  8w  d   h  Rp?MRp?ii ; i\        T4      R,           \        T4      ,           # )z}A SID could not be allocated for restoring the domain. Either no RID Set was found on this DC, or the RID Set was not usable.z‰To initialise this DC's RID pools, obtain a RID Set from this domain's RID master, or run samba-tool dbcheck to fix the existing RID Set.zCannot create backupNÚ-ú<SID=%s>úshow_deleted:1zshow_recycled:1)ÚscopeÚbaseÚattrsÚcontrolsz]Cannot create backup - this DC's RID pool is corrupt, the next SID (%s) appears to be in use.zCCannot create backup - this DC's RID pool is corrupt, the next SID z points to existing object z1. Please run samba-tool dbcheck on the source DC.)Únext_free_ridr   Úinfor   r   Úget_domain_sidÚstrÚsearchÚldbÚ
SCOPE_BASEÚlenÚdnÚargsÚERR_NO_SUCH_OBJECT)
ÚsamdbÚloggerÚridÚerrÚsidÚsid_for_restoreÚresÚeÚenumÚemsgs
   &&        Ú</usr/lib/python3/dist-packages/samba/netcmd/domain/backup.pyÚget_sid_for_restorerI   A   sV  € ð	8Ø×!Ñ!Ó#ˆô �%×&Ñ&Ó(Ó
)€CÜ˜#“h •n¤s¨3£xÕ/€OðØ�l‰l¤§¡Ø *¨_Õ <Ø!#Ø%5Ø%6ð%8ð ó 9ˆô
 ˆs‹8�qŒ=äð  Ið  /õ /ó 0ð 0õ ó ,¨S°­V¯Y¬Yð	8ó 9ð 	9øô5 ô 8Ø�‰ð 5ô 	6ð 	�‰ð 3ô 	4ô Ð1°3Ó7Ð7ûð8ûô> �<‰<ô Ø—v‘v‰ˆØ”3×)Ñ)Ô)àô *ûðúô ˆs‹8�c�>œC ›HÕ$Ð$s0   ‚C ÁA3D ÃC?Ã.C:Ã:C?ÄEÄ$E Å Ec                ó  € \         P                  ! 4       pVP                  VP                  4       VP	                  4       pVP                  \        4       \        P                  ! V RW2R7      pVP                  V4       V# )z7Returns an SMB connection to the sysvol share on the DCÚsysvol)ÚlpÚcreds)	Ús3paramÚget_contextÚloadÚ
configfileÚget_smb_signingÚset_smb_signingr)   ÚlibsmbÚConn)ÚserverrL   rM   Ús3_lpÚsaved_signing_stateÚconns   &&&   rH   Úsmb_sysvol_connrZ   q   sh   € ô ×ÒÓ!€EØ	‡J�Jˆr�}‰}Ôð  ×/Ñ/Ó1ÐØ	×ÑÔ.Ô/Ü�;Š;�v˜x¨EÔ?€Dà	×ÑÐ-Ô.Ø€Kó    c                  óz   € \         P                   P                  4       P                  4       P                  R R4      # )Ú:r,   )ÚdatetimeÚnowÚ	isoformatÚreplace© r[   rH   Úget_timestamprc   €   s-   € Ü×Ñ× Ñ Ó"×,Ñ,Ó.×6Ñ6°s¸CÓ@Ð@r[   c                 óV   € R V: RV: R2p\         P                  P                  W4      # )zsamba-backup-r,   z.tar.bz2)ÚosÚpathÚjoin)Ú	targetdirÚnameÚtime_strÚfilenames   &&& rH   Úbackup_filepathrl   „   s   � Û/3³XÐ>€HÜ�7‰7�<‰<˜	Ó,Ð,r[   c                 ó  a€ \         P                  ! R 4      p\        V R4      ;_uu_ 4       o\        V3R lR4       F  pVP	                  V4       K  	  RRR4       VP                  4       #   + '       g   i     TP                  4       # ; i)Úsha256Úrbc                  ó&   <€ S P                  R 4      # )i   )Úread)Úfs   €rH   Ú<lambda>Ú"create_sha256sum.<locals>.<lambda>Œ   s   ø€  !§&¡&¨¤-r[   r[   N)ÚhashlibÚnewÚopenÚiterÚupdateÚ	hexdigest)rk   ÚhashÚchunkrr   s   &  @rH   Úcreate_sha256sumr}   ‰   sj   ø€ Ü�;Š;�xÓ €DÜ	ˆh˜×	Ô	 ÜÔ/°Ö5ˆEØ�K‰K˜Öñ 6÷ 
ð �>‰>ÓÐ÷ 
Ö	ð �>‰>ÓÐús   ¬)A-Á-B	c                 óª   € V P                  R V,          4       \        P                  ! VR4      pVP                  VRR7       VP	                  4        R# )zCreating backup file %s...úw:bz2z./©ÚarcnameN)r4   Útarfilerw   ÚaddÚclose)r?   Útmpdirrl   Útfs   &&& rH   Úcreate_backup_tarr‡   ‘   s=   € à
‡K�KÐ,¨Õ>Ô?Ü	�Š�o wÓ	/€BØ‡F�Fˆ6˜4€FÔ Ø‡H�H†Jr[   c                 óÀ  € \        \        P                  P                  V R 4      R4      p \        P                  P                  4       P                  R4      pVP                  RV,          4       VP                  RVP                  R4      ,          4       VP                  RV: RV: R24       VP                  R	VP                  R
4      : RVP                  R4      P                  4       : R24       VP                  R\        V4      ,          4       V'       d   VP                  RV,          4       VP                  4        R#   TP                  4        i ; i)ú
backup.txtÚwz%Y-%b-%d %H:%M:%SzBackup created %s
zUsing samba-tool version: %s
zserver stringzDomain z backup, using DC 'z'
zBackup for domain Ú	workgroupú (NetBIOS), Úrealmz (DNS realm)
z#Backup contains domain secrets: %s
z%s
N)rw   re   rf   rg   r^   r_   ÚstrftimeÚwriteÚgetÚlowerr6   r„   )rh   rL   Úbackup_typerV   Úinclude_secretsÚ
extra_inforr   rj   s   &&&&&&  rH   Úcreate_log_filer•   ™   sñ   € ô
 	ŒR�W‰W�\‰\˜) \Ó2°CÓ8€AðÜ×$Ñ$×(Ñ(Ó*×3Ñ3Ð4GÓHˆØ	�‰Ð%¨Õ0Ô1Ø	�‰Ð0°2·6±6¸/Ó3JÕJÔKØ	�Š³{ÃFÐKÔLØ	�ŠØ—‘˜Ö$ b§f¡f¨W£o×&;Ñ&;Ö&=ð?ô 	@à	�‰Ð6¼¸_Ó9MÕMÔNßØ�G‰G�F˜ZÕ'Ô(à	�‰Ž	øˆ�‰�	ús   ¬DE ÅEc                 óÚ   € \         P                  ! 4       p\         P                  ! V R 4      Vn        \         P                  ! V\         P
                  V4      W1&   V P                  V4       R# )ú@SAMBA_DSDBN)r8   ÚMessageÚDnr;   ÚMessageElementÚFLAG_MOD_ADDÚmodify)r>   ÚmarkerÚvalueÚms   &&& rH   Úadd_backup_markerr    ¯   sF   € Ü�Š‹€AÜ�6Š6�%˜Ó'€A„DÜ×"Ò" 5¬#×*:Ñ*:¸FÓC€A�IØ	‡L�L�†Or[   c                 ó<  € Vf   \        R4      h\        P                  P                  V4      '       g1   V P	                  RV,          4       \        P
                  ! V4       R # \        P                  P                  V4      '       g   \        RV,          4      hR # )NzTarget directory requiredzCreating targetdir %s...z%s is not a directory)r   re   rf   Úexistsr4   ÚmakedirsÚisdir)r?   rh   s   &&rH   Úcheck_targetdirr¥   ¶   sn   € ØÒÜÐ6Ó7Ð7ä�7‰7�>‰>˜)×$Ò$Ø�‰Ð.°Õ:Ô;Ü
�Š�IÖÜ�W‰W�]‰]˜9×%Ò%ÜÐ2°YÕ>Ó?Ð?ñ &r[   c                ó°  € VP                  4       pRV: R\        P                  : R2pRV: R2pVP                  VP	                  4       \
        P                  VR7      p\        V^ ,          R,          4      p\        P                  ! ^^ 4      pV P                  RV: RV: 24       V P                  R	V,          4       VP                  WGR
VR7       R# )zASets a randomly generated password for the backup DB's admin userz(objectsid=r,   Ú)z(&(objectClass=user))r0   r/   Ú
expressionÚsamaccountnamezSetting z password in backup to: z7Run 'samba-tool user setpassword %s' after restoring DBF)Úforce_change_at_next_loginÚusernameN)r5   r   ÚDOMAIN_RID_ADMINISTRATORr7   Ú	domain_dnr8   ÚSCOPE_SUBTREEr6   ÚsambaÚgenerate_random_passwordr4   Úsetpassword)r?   r>   Ú	domainsidÚmatch_adminÚsearch_exprrD   r«   Ú	adminpasss   &&      rH   Úset_admin_passwordr¶   Ã   s¿   € ð ×$Ñ$Ó&�IÛ)2Ü)1×)JÔ)JðL�Kã/:Ð<€Kð �,‰,˜EŸO™OÓ-´S×5FÑ5FØ"-ð ó /€Cä�3�q•6Ð*Õ+Ó,€Hä×.Ò.¨r°2Ó6€IØ
‡K‚K»(ÂIÐNÔOØ
‡K�KÐIØõô à	×Ñ�kÈØ'ð ö )r[   c                   óò   a € ] tR t^Ùt o RtRtR]P                  R]P                  /t	]
! RR]R7      ]
! R]R	R
7      ]
! RRRRR7      ]
! RRRRR.R]! 4       ,          R7      ]
! RRRRR7      .tRR ltRtV tR# )Úcmd_domain_backup_onlinea£  Copy a running DC's current DB into a backup tar file.

Takes a backup copy of the current domain from a running DC. If the domain
were to undergo a catastrophic failure, then the backup file can be used to
recover the domain. The backup created is similar to the DB that a new DC
would receive when it joins the domain.

Note that:
- it's recommended to run 'samba-tool dbcheck' before taking a backup-file
  and fix any errors it reports.
- all the domain's secrets are included in the backup file.
- although the DB contents can be untarred and examined manually, you need
  to run 'samba-tool domain backup restore' before you can start a Samba DC
  from the backup file.z6%prog --server=<DC-to-backup> --targetdir=<output-dir>Ú	sambaoptsÚcredoptsú--serverúThe DC to backup©ÚhelpÚtypeú--targetdirz%Directory to write the backup file to)r¿   r¾   ú--no-secretsÚ
store_trueFú-Exclude secret values from the backup created©ÚactionÚdefaultr¾   ú--backend-storeÚchoiceÚBACKENDSTOREÚtdbÚmdbú7Specify the database backend to be used (default is %s)©r¿   ÚmetavarÚchoicesr¾   z--no-sysvolz&Exclude sysvol from the backup createdNc                ó\  € V P                  4       pVP                  \        P                  4       VP	                  4       p	VP                  V	4      p
Vf   \        R4      h\        W„4       \        P                  ! VR7      pV'       * p \        WŠV	WÃRVVR7      pVP                  p?\        RV,           V
\        4       V	R7      p\        Wø4      pVP                  4       pV'       gy   VP!                  R4       \"        P$                  P'                  VR4      p\)        W9V
4      p\+        VVVP-                  4       4       \.        P0                  ! VP2                  4       \        VP4                  \        4       V	\6        P8                  R	7      p\;        4       p\=        VR
V4       \=        VRV4       \=        VRR4       V'       d   \?        VV4       \A        VVV4      p\C        W¹RW<4       \E        W‹V4       \.        P0                  ! V4       R #   \.        P0                  ! T4       i ; i)NúServer required©ÚdirÚSAMBA_INTERNAL)r?   rM   rL   r“   rV   Údns_backendrh   Úbackend_storeúldap://©ÚurlÚcredentialsÚsession_inforL   z$Backing up sysvol files (via SMB)...úsysvol.tar.gz©rÙ   rÛ   rL   ÚflagsÚ
backupDateÚsidForRestoreÚ
backupTypeÚonline)#Ú
get_loggerÚsetLevelÚloggingÚDEBUGÚget_loadparmÚget_credentialsr   r¥   ÚtempfileÚmkdtempr   Úpathsr   r   rI   Údomain_dns_namer4   re   rf   rg   rZ   r   r5   ÚshutilÚrmtreerK   r>   r8   ÚFLG_DONT_CREATE_DBrc   r    r¶   rl   r•   r‡   )Úselfr¹   rº   rV   rh   Ú
no_secretsrÖ   Ú	no_sysvolr?   rL   rM   r…   r“   Úctxrë   Ú
remote_samÚnew_sidr�   Ú
sysvol_tarÚsmb_connr>   rj   Úbackup_files   &&&&&&&&               rH   ÚrunÚcmd_domain_backup_online.runþ   sÄ  € à—‘Ó"ˆØ�‰œŸ™Ô&à×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆð Š>ÜÐ0Ó1Ð1ä˜Ô*ä×!Ò! iÔ0ˆð )œ.ˆð,	"Ü F¸BØ-<Ø)9ÀVØ+8ô:ˆCð —I‘IˆEØô  9¨vÕ#5À5Ü,:Ó,<ÀôEˆJä)¨*Ó=ˆGØ×.Ñ.Ó0ˆEçà—‘ÐBÔCÜŸW™WŸ\™\¨&°/ÓB�
Ü*¨6°uÓ=�Ü˜h¨
°J×4MÑ4MÓ4OÔPô —’˜eŸl™lÔ+ô ˜eŸk™k¼Ó8HÈRÜ #× 6Ñ 6ô8ˆEä$“ˆHÜ˜e \°8Ô<Ü˜e _°gÔ>Ü˜e \°8Ô<÷ Ü" 6¨5Ô1ô *¨)°U¸HÓEˆKÜ˜F¨°&ÔJÜ˜f¨kÔ:ä�MŠM˜&Ö!øŒF�MŠM˜&Õ!ús   Â
E1H ÈH+rb   )NNNNFNF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚsynopsisÚoptionsÚSambaOptionsÚCredentialsOptionsÚtakes_optiongroupsr   r6   r   Útakes_optionsrù   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @rH   r¸   r¸   Ù   s«   ø‡ € ñð H€Hà�W×)Ñ)Ø�G×.Ñ.ðÐñ 	ˆzÐ 2¸Ô=Ùˆ} 3Ø;ô	=áˆ~ l¸EØCô	EáÐ  x¸Ø˜u�~ð!Ù#<Ó#>õ?ô	@ñ 	ˆ} \¸5Ø;ô	=ð€M÷>"ò >"r[   r¸   c                   ó
  a € ] tR tRt o RtRt]! RR]R7      ]! RR]R7      ]! R	R
]R7      ]! RRRRR7      ]! RRRRR7      ]! RR]R7      .tR]	P                  R]	P                  /tR tR tR tR tR tR tR R ltRtV tR# )!Úcmd_domain_backup_restorei?  ah  Restore the domain's DB from a backup-file.

This restores a previously backed up copy of the domain's DB on a new DC.

Note that the restored DB will not contain the original DC that the backup
was taken from (or any other DCs in the original domain). Only the new DC
(specified by --newservername) will be present in the restored DB.

Samba can then be started against the restored DB. Any existing DCs for the
domain should be shutdown before the new DC is started. Other DCs can then
be joined to the new DC to recover the network.

Note that this command should be run as the root user - it will fail
otherwise.zQ%prog --backup-file=<tar-file> --targetdir=<output-dir> --newservername=<DC-name>z--backup-filezPath to backup filer½   rÀ   zPath to write toz--newservernamezName for new serverz	--host-ipÚstringÚ	IPADDRESSzset IPv4 ipaddress)r¿   rÎ   r¾   z
--host-ip6Ú
IP6ADDRESSzset IPv6 ipaddressz--sitezSite to add the new server inr¹   rº   c                ó
  € \        V4      pVP                  p	VP                  4       P                  4       p
VP                  P                  4       pTpVP                  P                  4       p\        VP                  4       4      p\        W)4      p\        W)4      p\        WV4      p\        WV4      pVf   Vf   \        R4      hVP                  RV,          4       VP                  R4       \        W.WyW«WÍWVVVVRR7       R# )zQ
Registers the new realm's DNS objects when a renamed domain backup
is restored.
Nz+Please specify a host-ip for the new serverzDNS realm was renamed to %sz*Populating DNS partitions for new realm...F)Úadd_root)r   ÚdomaindnÚget_root_basednÚget_linearizedÚ	dnsdomainr‘   Únetbiosnamer   r5   r!   r"   r   r   r   r4   r    )rð   r?   r>   rL   ÚntdsguidÚhost_ipÚhost_ip6ÚsiteÚnamesr  Úforestdnr  Ú	dnsforestÚhostnamer²   Údnsadmins_sidÚ
domainguids   &&&&&&&&         rH   Úregister_dns_zoneÚ+cmd_domain_backup_restore.register_dns_zonea  sî   € ô ˜B“ˆØ—>‘>ˆØ×(Ñ(Ó*×9Ñ9Ó;ˆØ—O‘O×)Ñ)Ó+ˆ	Øˆ	Ø×$Ñ$×*Ñ*Ó,ˆÜ˜E×0Ñ0Ó2Ó3ˆ	Ü)¨%Ó:ˆÜ# EÓ4ˆ
ô $ F°Ó8ˆÜ% f°(Ó;ˆàŠ?˜xÒ/ÜÐLÓMÐMà�‰Ð1°IÕ=Ô>Ø�‰Ð@ÔAô 	! °4Ø!)°iØ!(°JÀØ!.¸÷	@r[   c                óæ   € VP                  4        \        VRRRRR7      p\        VRR4       RR.p\        VRR4       VR	.,          pR
pRV.pVP                  WSR7       VP	                  4        R# )z3Fixes attributes that reference the old/removed DCsTF©ÚquietÚfixÚyesÚin_transactionÚ(fix_all_old_dn_string_component_mismatchÚALLÚlastKnownParentÚinterSiteTopologyGeneratorÚ!remove_plausible_deleted_DN_linkszmsDS-NC-Replica-Locationsúsearch_options:1:2r.   )r2   r1   N©Útransaction_startr   ÚsetattrÚcheck_databaseÚtransaction_commit)rð   r>   Úchkr1   Úcross_ncs_ctrlr2   s   &&    rH   Úfix_old_dc_referencesÚ/cmd_domain_backup_restore.fix_old_dc_references‚  sˆ   € ð 	×ÑÔ!Ü�e 4¨T°uØ%)ô+ˆô 	�Ð?ÀÔGØ"Ð$@ÐAˆô 	�Ð8¸%Ô@ØÐ-Ð.Õ.ˆà-ˆØ$ nÐ5ˆØ×Ñ HÐÔ:Ø× Ñ Ö"r[   c                ó>  € \         pRP                  V4      pVP                  VP                  4       \        P
                  VR7      p\        V4      ^ 8X  dF   VP                  RP                  V4      4       \        P                  ! WP                  4       V4       V# )z5Creates the default site, if it doesn't already existz(&(cn={0})(objectclass=site))©r/   r¨   zCreating default site '{0}')
r   Úformatr7   Úget_config_basednr8   r®   r:   r4   r&   Úcreate_site)rð   r>   r?   Úsitenamer´   rD   s   &&&   rH   Úcreate_default_siteÚ-cmd_domain_backup_restore.create_default_site›  s…   € ô ˆØ5×<Ñ<¸XÓFˆØ�l‰l˜5×2Ñ2Ó4¼C×<MÑ<MØ&1ð ó 3ˆô ˆs‹8�qŒ=Ø�K‰KÐ5×<Ñ<¸XÓFÔGÜ×Ò˜e×%<Ñ%<Ó%>ÀÔIàˆr[   c                ó€  € . ROpVP                  \        P                  ! VR4      \        P                  VR7      p\        P                  ! 4       p\        P                  ! VR4      Vn        V F:  pWS^ ,          9   g   K  \        P                  ! . \        P                  V4      WE&   K<  	  VP                  V4       R# )z-Remove DB markers added by the backup processr—   ©r0   r/   r1   N)rà   ÚbackupRenamerß   rá   )	r7   r8   r™   r9   r˜   r;   rš   ÚFLAG_MOD_DELETErœ   )rð   r>   ÚmarkersrD   rŸ   Úattrs   &&    rH   Úremove_backup_markersÚ/cmd_domain_backup_restore.remove_backup_markers©  s�   € ò PˆØ�l‰l¤§¢ u¨mÓ <Ü!$§¡Ø!(ð ó *ˆô
 �KŠK‹MˆÜ�vŠv�e˜]Ó+ˆŒãˆDØ˜1•vŽ~Ü×,Ò,¨R´×1DÑ1DÀdÓK�“ñ ð 	�‰�QŽr[   c                óò   € VP                  \        P                  ! VR 4      \        P                  RR.R7      pRV^ ,          9   d   \	        V^ ,          R,          4      pV# RV^ ,          9   d   RpV# RpV# )r—   rA  rá   r@  Úrenamerâ   )r7   r8   r™   r9   r6   )rð   r>   rD   r’   s   &&  rH   Úget_backup_typeÚ)cmd_domain_backup_restore.get_backup_type¼  sƒ   € Ø�l‰l¤§¢ u¨mÓ <Ü!$§¡Ø"0°,Ð!?ð ó Aˆð ˜3˜q�6Ô!Ü˜c !�f \Õ2Ó3ˆKð Ðð ˜s 1�vÔ%Ø"ˆKð Ðð #ˆKàÐr[   c                ó¤  € V FÉ  p\        W4      p\        P                  ! 4       p^Vn        WEP                  n        \        V4      VP                  n        \        V4      p\        P                  ! 4       p\        P                  ! W4      Vn        \        P                  ! V\        P                  R4      VR&   VP                  V4       KË  	  R# )z?Ensures the UTDV used by DRS is correct after an offline backupÚreplUpToDateVectorN)r'   r   ÚreplUpToDateVectorBlobÚversionÚctrÚcursorsr:   Úcountr(   r8   r˜   r™   r;   rš   ÚFLAG_MOD_REPLACErœ   )rð   r>   Ú
partitionsÚncÚutdvÚ	utdv_blobÚ	new_valuerŸ   s   &&&     rH   Úsave_uptodate_vectorsÚ/cmd_domain_backup_restore.save_uptodate_vectorsÍ  sŸ   € ãˆBä$ UÓ/ˆDô !×7Ò7Ó9ˆIØ !ˆIÔØ$(�M‰MÔ!Ü"% d£)ˆI�M‰MÔÜ  Ó+ˆIä—’“ˆAÜ—6’6˜%Ó$ˆAŒDÜ&)×&8Ò&8¸Ü9<×9MÑ9MØ9Mó'OˆAÐ"Ñ#ð �L‰L˜ŽOó! r[   Nc	                óÔ  € V'       d&   \         P                  P                  V4      '       g   \        R 4      hVf   \        R4      h\         P                  P                  V4      '       dL   \         P                  ! V4      '       d0   \         P
                  P                  R4      R8w  d   \        R4      hV'       g   \        R4      h\        P                  ! 4       p	V	P                  \        P                  4       V	P                  \        P                  ! \        P                  4      4       VP                  4       p\         P                  P!                  V4      p\"        P$                  ! V4      p
V
P'                  V4       V
P)                  4        \         P*                  ! VRR7       \         P                  P-                  VR	R
4      p\.        P0                  ! W»R,           4       VP3                  4       pV'       d/   V	P5                  RV,          4       \.        P0                  ! WË4       \6        P8                  P;                  4       pVP=                  V4       \         P                  P-                  VR4      p\         P                  P-                  VR4      p\?        V\A        4       V\B        PD                  R7      pV PG                  V4      pVf3   V PI                  VV	4      pV	P5                  RPK                  V4      4       VPM                  R\B        PN                  R.R7      pV^ ,          P                  R4       Uu. uF  p\Q        V4      NK  	  ppVR8X  d   V PS                  VV4       VPU                  V4      p\W        V	VWØVVR7      pVVn,        VVn-        \6        P\                  P^                  \6        P\                  P`                  ,          Vn1        V	P5                  R4       \e        WµVPf                  VPh                  WMRR7       VPM                  \B        Pj                  ! VR4      \B        PN                  R.R7      pV^ ,          P                  R4      ^ ,          pV	P5                  R\Q        V4      ,           4        VPm                  \o        \Q        V4      4      R7       \B        P‚                  ! 4       p \B        Pj                  ! TR+4      T n@        \Q        TP„                  4      p!\B        P†                  ! R,T!,          \B        Pˆ                  R-4      T R-&   TP‹                  T 4       TR.8X  d!   T P�                  T	TTTP„                  YgT4       \         P                  P-                  TR/4      p"\�        T"\A        4       T\B        PD                  R07      p#\‘        T#TPf                  TPh                  TP’                  TP”                  TP–                  TP˜                  TPš                  \œ        Pž                  R17	       TP¡                  4       p$\6        P¢                  ! TP¥                  4       4      p%R2T$3R3T%3.p&T& F&  w  p'p(T(T9   g   K  T P§                  T'TRRRR4R57       K(  	  RB F  p'T P©                  T'TR4R57       K  	  R6p)TPM                  TP«                  4       \B        P¬                  T)R77      pT F:  p \Q        T P                  R84      ^ ,          4      p*T*T8w  g   K-  \¯        TT	T*4       K<  	  T F—  p+\B        P‚                  ! 4       p,\B        Pj                  ! TT+4      T,n@        \B        P†                  ! . \B        Pˆ                  R94      T,R9&   \B        P†                  ! . \B        Pˆ                  R:4      T,R:&   TP‹                  T,4       K™  	  \±        T4       \±        T4       \         P                  P-                  TR;4      p-TP                  R<R=4      p.\         P                  P                  T.4      '       g   \         P²                  ! T.4       \         P                  Pµ                  T-4      '       d&   \·        T-T.TT4       \         P¸                  ! T-4       MT	P»                  R>4       T	P5                  R?4       T P½                  T4       T P¿                  T4       T	P5                  R@T,          4       T	P5                  RA4       R# u upi   \p         Edr   pTPr                  w  ppT\B        Pt                  8w  d   h . p TPM                  \B        Pj                  ! TRT,          4      \B        PN                  R.RR .R!7      pM=  \p         d0   pTPr                  w  ppT\B        Pv                  8w  d   h  Rp?MRp?ii ; i\y        T4      ^8w  d   h TP{                  RT^ ,          R,          ^ ,          4      pTP}                  R"4      pT	P                  R#T,          4       T	P                  R$4       T	P                  R%4       T	P                  R&T,          4       \        R'T^ ,          P€                  : R(T: R)T: R*24      hRp?ii ; i)CzBackup file not found.Nz!Please specify a target directoryÚSAMBA_SELFTESTÚ1zTarget directory is not emptyzServer name requiredií  )ÚmodeÚetczsmb.confz.origz&Using %s as restored domain's smb.confÚprivateúsam.ldbrÝ   zAdding new DC to site '{0}'Ú ÚnamingContextsr@  Úoffline)rM   rL   r  Úforced_local_samdbÚnetbios_namez#Updating basic smb.conf settings...z"active directory domain controller)rL   Ú
serverroler—   rà   zCreating account with SID: )Úspecified_sidr-   Ú
objectGUIDzshow_deleted:0zshow_recycled:0)r0   r/   r1   r2   zutf-8z|The RID Pool on the source DC for the backup in %s may be corrupt or in conflict with SIDs already allocated in the domain. zaRunning 'samba-tool dbcheck' on the source DC (and obtaining a new backup) may correct the issue.z@Alternatively please obtain a new backup against a different DC.zVThe SID we wish to use (%s) is recorded in @SAMBA_DSDB as the sidForRestore attribute.zCDomain restore failed because there is already an existing object (z) with SID z and objectGUID zT.  This conflicts with the new DC account we want to add for the restored domain.   z@ROOTDSEz	<GUID=%s>ÚdsServiceNamerH  zsecrets.ldb)rÛ   rL   rÞ   )Údomainr�   r  r  r²   ÚmachinepassÚkey_version_numberÚsecure_channel_typeÚ	domaindnsÚ	forestdnsT)Úforcez*(&(objectClass=Server)(serverReference=*))r8  ÚcnÚrepsFromÚrepsTorÜ   rf   rK   zback-up has no sysvol dataz4Fixing up any remaining references to the old DCs...z'Backup file successfully restored to %szEPlease check the smb.conf settings are correct before starting samba.)r@   ÚpdcÚnamingÚinfrastructureÚschema)`re   rf   r¢   r   ÚlistdirÚenvironr�   rå   Ú	getLoggerrä   ræ   Ú
addHandlerÚStreamHandlerÚsysÚstdoutÚupperÚabspathr‚   rw   Ú
extractallr„   Úchmodrg   rí   ÚcopyfileÚget_loadparm_pathr4   r¯   r   ÚLoadParmrP   r   r   r8   rï   rI  r=  r9  r7   r9   r6   rX  rè   r   Únc_listÚfull_nc_listÚdsdbÚUF_SERVER_TRUST_ACCOUNTÚUF_TRUSTED_FOR_DELEGATIONÚuserAccountControlr   Údomain_namer�   r™   Újoin_add_objectsr   r   r<   ÚERR_CONSTRAINT_VIOLATIONr=   r:   Úschema_format_valueÚdecodeÚerrorr;   r˜   Ú	ntds_guidrš   rR  rœ   r   r   r   r  ÚmynameÚdomsidÚ	acct_passrl  r   ÚSEC_CHAN_BDCr­   Údn_from_dns_nameÚforest_dns_nameÚseize_dns_roleÚ
seize_roler:  r®   r   r   r£   Úisfiler	   ÚremoveÚwarningr5  rE  )/rð   r¹   rº   rø   rh   Únewservernamer  r  r  r?   r†   ÚsmbconfÚcli_smbconfrL   Úprivate_dirÚ
samdb_pathr>   r’   rD   ÚrÚncsrM   ró   rB   rE   rF   rG   Údup_resÚdup_eÚdup_enumÚ_Ú
objectguidrŸ   r’  Úsecrets_pathÚsecrets_ldbr­   Ú	forest_dnÚ	dns_rolesÚroler;   r´   rq  rT  Úmsgrö   Údest_sysvol_dirs/   &&&&&&&&&                                      rH   rù   Úcmd_domain_backup_restore.runá  sY  € ÷ ¤§¡§¡¨{× ;Ò ;ÜÐ7Ó8Ð8ØÒÜÐBÓCÐCä�G‰G�N‰N˜9×%Ò%¬"¯*ª*°Y×*?Ò*?Ü�J‰J�N‰NÐ+Ó,°Ô3ÜÐ>Ó?Ð?ßÜÐ5Ó6Ð6ä×"Ò"Ó$ˆØ�‰œŸ™Ô&Ø×Ñœ'×/Ò/´·
±
Ó;Ô<ð &×+Ñ+Ó-ˆô —G‘G—O‘O IÓ.ˆ	Ü�\Š\˜+Ó&ˆØ
�‰�iÔ Ø
�‰Œ
ä
�Š� Õ'ô —'‘'—,‘,˜y¨%°Ó<ˆÜ�Š˜¨7Õ!2Ô3ð  ×1Ñ1Ó3ˆßØ�K‰KÐ@À;ÕNÔOÜ�OŠO˜KÔ1ä�[‰[×!Ñ!Ó#ˆØ
�‰�Ôô —g‘g—l‘l 9¨iÓ8ˆÜ—W‘W—\‘\ +¨yÓ9ˆ
Ü˜*´>Ó3CÈÜ×2Ñ2ô4ˆà×*Ñ*¨5Ó1ˆàŠ<ð ×+Ñ+¨E°6Ó:ˆDØ�K‰KÐ5×<Ñ<¸TÓBÔCð �l‰l ¬#¯.©.Ø"2Ð!3ð ó 5ˆà" 1�vŸz™zÐ*:Ô;Ó<Ñ;˜!Œs�1ŽvÑ;ˆÐ<ð ˜)Ô#Ø×&Ñ& u¨cÔ2ð
 ×(Ñ(¨Ó,ˆÜ˜F¨%°BØ/4Ø)6ô8ˆð ˆŒØˆÔÜ"'§*¡*×"DÑ"DÜ"'§*¡*×"FÑ"Fõ#GˆÔð 	�‰Ð9Ô:Ü�W¨S¯_©_Ø—Y‘Y 	Ø Dõ	Fð
 �l‰l¤§¢ u¨mÓ <Ü!$§¡Ø"1Ð!2ð ó 4ˆð �!�f�j‰j˜Ó)¨!Õ,ˆØ�‰Ð1´C¸³HÕ<Ô=ð+	AØ× Ñ ¬w´s¸3³xÓ/@Ð ÔAôX �KŠK‹MˆÜ�vŠv�e˜ZÓ(ˆŒÜ˜Ÿ™Ó&ˆ	Ü ×/Ò/°¸iÕ0GÜ03×0DÑ0DØ0?óAˆˆ/Ñð 	�‰�QŒð
 ˜(Ô"Ø×"Ñ" 6¨5°"°c·m±mØ#*°dô<ô —w‘w—|‘| K°Ó?ˆÜ˜,´^Ó5EÈ"Ü #× 6Ñ 6ô8ˆä˜K°·±Ø"%§)¡)°s·}±}Ø(+¯
©
¸c¿j¹jØ(+¯©Ø/2×/EÑ/EÜ04×0AÑ0Aõ	Cð —O‘OÓ%ˆ	Ü×*Ò*¨5×+@Ñ+@Ó+BÓCˆ	Ø! 9Ð-Ø! 9Ð-ð/ˆ	ã!‰HˆD�"Ø�SŽyØ×#Ñ# D¨%°°t¸TÈÐ#ÖNñ "ó
 IˆDØ�O‰O˜D %¨tˆOÖ4ñ Ið
 CˆØ�l‰l˜5×2Ñ2Ó4¼C×<MÑ<MØ&1ð ó 3ˆãˆAÜ�Q—U‘U˜4“[ •^Ó$ˆBØ�]Ö"Ü˜% ¨Ö,ñ ó ˆBÜ—+’+“-ˆCÜ—V’V˜E 2Ó&ˆCŒFä!×0Ò0°Ü14×1EÑ1EØ1;ó=ˆC�
‰Oô  ×.Ò.¨rÜ/2×/CÑ/CØ/7ó9ˆC�‰Mð �L‰L˜Öñ ô 	' uÔ-Ü& uÔ-ô —W‘W—\‘\ )¨_Ó=ˆ
ØŸ&™& ¨Ó2ˆÜ�w‰w�~‰~˜o×.Ò.Ü�KŠK˜Ô(Ü�7‰7�>‰>˜*×%Ò%Ü˜: ¸¸wÔGÜ�IŠI�jÕ!à�N‰NÐ7Ô8ð 	�‰ÐJÔKØ×"Ñ" 5Ô)ð 	×"Ñ" 5Ô)à�‰Ð=À	ÕIÔJØ�‰ð &ö 	'ùòO =øôJ õ )	AØŸ6™6‰LˆT�4Ø”s×3Ñ3Ô3ØàˆGð	ØŸ,™,¬C¯FªF°5¸*ÀsÕ:JÓ,KÜ-0¯^©^Ø.:¨^Ø1AØ1Bð1Dð 'ó E‘øô
 ô Ø %§
¡
‘�˜1Øœs×5Ñ5Ô5Øô 6ûðúô
 �G“ Ô!Øà×2Ñ2°<Ø7>¸qµzÀ,Õ7OÐPQÕ7RóTˆJà#×*Ñ*¨7Ó3ˆJØ�L‰Lð +ð .9õ9ô :ð �L‰Lð Rô Sà�L‰Lð 3ô 4à�L‰Lð Gàõô  õ ð !(¨¥
§¤«s³Jð @ó Að AûðG)	AúsJ   Íc%Ò$c* ã*i'ã6'i"äAe!å i"å!få,%fæi"æfæCi"é"i'rb   )NNNNNNNN)rû   rü   rý   rþ   rÿ   r   r   r6   r  r  r  r  r  r   r5  r=  rE  rI  rX  rù   r  r  r  s   @rH   r  r  ?  s½   ø‡ € ñð,€Hñ 	ˆÐ%:ÀÔEÙˆ}Ð#5¸CÔ@ÙÐ Ð'<À3ÔGÙˆ{ °;Ø(ô	*áˆ| (°LØ(ô	*áˆxÐ=ÀCÔHð	€Mð 	�W×)Ñ)Ø�G×.Ñ.ðÐò
@òB#ò2òò&ò"÷(d'ò d'r[   r  c                   ó  a € ] tR tRt o RtRtR]P                  R]P                  /t	]
! RR]R7      ]
! R	R
]R7      ]
! RRRRR7      ]
! RRRRR7      ]
! RRRRR.R]! 4       ,          R7      .tRR.tR tR tR tR tR"R  ltR!tV tR# )#Úcmd_domain_backup_renameiÈ  an  Copy a running DC's DB to backup file, renaming the domain in the process.

Where <new-domain> is the new domain's NetBIOS name, and <new-dnsrealm> is
the new domain's realm in DNS form.

This is similar to 'samba-tool backup online' in that it clones the DB of a
running DC. However, this option also renames all the domain entries in the
DB. Renaming the domain makes it possible to restore and start a new Samba
DC without it interfering with the existing Samba domain. In other words,
you could use this option to clone your production samba domain and restore
it to a separate pre-production environment that won't overlap or interfere
with the existing production Samba domain.

Note that:
- it's recommended to run 'samba-tool dbcheck' before taking a backup-file
  and fix any errors it reports.
- all the domain's secrets are included in the backup file.
- although the DB contents can be untarred and examined manually, you need
  to run 'samba-tool domain backup restore' before you can start a Samba DC
  from the backup file.
- GPO and sysvol information will still refer to the old realm and will
  need to be updated manually.
- if you specify 'keep-dns-realm', then the DNS records will need updating
  in order to work (they will still refer to the old DC's IP instead of the
  new DC's address).
- we recommend that you only use this option if you know what you're doing.
zR%prog <new-domain> <new-dnsrealm> --server=<DC-to-backup> --targetdir=<output-dir>r¹   rº   r»   r¼   r½   rÀ   z"Directory to write the backup filez--keep-dns-realmrÂ   Fz6Retain the DNS entries for the old realm in the backuprÄ   rÁ   rÃ   rÇ   rÈ   rÉ   rÊ   rË   rÌ   rÍ   Únew_domain_nameÚnew_dns_realmc                óÚ  € VP                  4       pVP                  V\        P                  R.RR7      pVP	                  4       pV EF  pVR,           EF  p	\        V	4      p	VP                  p
W99   g   K#  \        P                  ! RV,          VV	4      pVP                  RV: RV
: 24       \        P                  ! 4       pW¬n        \        P                  ! V\        P                  R4      VR&   VP                  V4       V'       g   Kº  VP                  RV	: RV
: 24       \        P                  ! V	\        P                  R4      VR&   VP                  V4       EK  	  EK"  	  R	# )
z?Updates dnsRoot for the partition objects to reflect the renameÚdnsRootz$(&(objectClass=crossRef)(dnsRoot=*))©r0   r/   r1   r¨   z%s$zAdding z dnsRoot to z	Removing z dnsRoot from N)Úget_partitions_dnr7   r8   ÚSCOPE_ONELEVELrì   r6   r;   ÚreÚsubr4   r˜   rš   r›   rœ   rB  )rð   r?   r>   Ú	old_realmÚdelete_old_dnsÚpartitions_dnrD   Ú	new_realmÚres_msgÚdns_rootr;   Únew_dns_rootrŸ   s   &&&&&        rH   Úupdate_dns_rootÚ(cmd_domain_backup_rename.update_dns_rootü  s8  € ð ×/Ñ/Ó1ˆØ�l‰l ´S×5GÑ5GØ"+ Ø&Lð ó Nˆð ×)Ñ)Ó+ˆ	ô ˆGà# I×.Ñ.�Ü˜x›=�Ø—Z‘Z�ØÖ(Ü#%§6¢6¨%°)Õ*;¸YØ*2ó$4�Là—K’K»\Ê2Ð NÔOäŸš›�AØ”DÜ#&×#5Ò#5°lÜ69×6FÑ6FØ6?ó$A�A�i‘Lð —L‘L ”O÷ &‘~ØŸšÃXÚEGð%Iô Jä'*×'9Ò'9¸(Ü:=×:MÑ:MØ:Có(E˜˜)™ð Ÿ™ QŸô- /ó r[   c                óŒ  € VP                  4       p\        P                  ! \        V4      4      pVP	                  4       pVP                  V\        P                  R.RV,          R7      pVP                  RV,          4       \        P                  ! 4       pV^ ,          P                  Vn	        \        P                  ! V\        P                  R4      VR&   VP                  V4       RV: RV: 2p	VP                  RV^ ,          P                  : RV	: 24       VP                  V^ ,          P                  V	R	.R
7       R# )z?Renames the domain partition object and updates its nETBIOSNameÚnETBIOSNamez	ncName=%sr¸  z+Changing backup domain's NetBIOS name to %szCN=Ú,z	Renaming z --> zrelax:0©r2   N)Úget_default_basednr8   Úbinary_encoder6   r¹  r7   rº  r4   r˜   r;   rš   rR  rœ   rH  )
rð   r?   r>   Únew_netbios_nameÚbase_dnÚnc_namer¿  rD   rŸ   Únew_dns
   &&&&      rH   Úrename_domain_partitionÚ0cmd_domain_backup_rename.rename_domain_partition#  s  € ð
 ×*Ñ*Ó,ˆÜ×#Ò#¤C¨£LÓ1ˆØ×/Ñ/Ó1ˆØ�l‰l ´S×5GÑ5GØ"/ Ø&1°GÕ&;ð ó =ˆð 	�‰ÐAØ$õ%ô 	&ä�KŠK‹MˆØ�1�v�y‰yˆŒÜ×-Ò-Ð.>Ü.1×.BÑ.BØ.;ó=ˆˆ-Ñð 	�‰�Q�ó  0²Ð?ˆØ�Š¨C°­F¯I¬I²vÐ>Ô?Ø�‰�S˜•V—Y‘Y °)°ˆÖ=r[   c                ó6  € VP                  4       pR V: RV: 2pVP                  RV,          4       VP                  VR.4       VP                  4       P	                  4       pRV: RV: 2pVP                  RV,          4       VP                  VR.4       R# )zDC=z#,CN=MicrosoftDNS,DC=DomainDnsZones,zDeleting old DNS zone %sztree_delete:1z
DC=_msdcs.z#,CN=MicrosoftDNS,DC=ForestDnsZones,N)rÊ  r4   Údeleter  r  )rð   r?   r>   r½  Úbasednr;   r  s   &&&&   rH   Údelete_old_dns_zonesÚ-cmd_domain_backup_rename.delete_old_dns_zones=  s…   € à×)Ñ)Ó+‰Û=FÊÐOˆØ�‰Ð.°Õ3Ô4Ø�‰�R˜/Ð*Ô+à×(Ñ(Ó*×9Ñ9Ó;‰ÛDMÚDLðNˆà�‰Ð.°Õ3Ô4Ø�‰�R˜/Ð*Ö+r[   c                ó°   € VP                  4        \        VRRRRR7      p\        VRR4       RpRV.pVP                  VR7       VP	                  4        R	# )
z@Fixes attributes (i.e. objectCategory) that still use the old DNTFr#  r(  r)  r-  r.   rÉ  Nr.  )rð   r>   r3  r4  r2   s   &&   rH   Úfix_old_dn_attributesÚ.cmd_domain_backup_rename.fix_old_dn_attributesJ  s`   € ð 	×ÑÔ!ä�e 4¨T°uØ%)ô+ˆô 	�Ð?ÀÔGØ-ˆØ$ nÐ5ˆØ×Ñ HÐÔ-Ø× Ñ Ö"r[   Nc
                ó¾  € V P                  4       p
V
P                  \        P                  4       VP	                  4       pVP                  V4      pVf   \        R4      h\        W¦4       V'       * pVP                  4       pVP                  4       p\        P                  ! V4      pV
P                  RV,          4       V
P                  RV,          4       V
P                  RV,          4       \        P                  ! VR7      pV'       * p\        WáW*WËVRW_V	R7      pVP                   pVV8X  d"   \"        P$                  ! V4       \        R4      hVP&                  pVV8X  d"   \"        P$                  ! V4       \        R	4      hVP)                  4        V=VP,                  p\/        R
V,           V\1        4       VR7      p\3        VV
4      p\4        P6                  P9                  VR4      p\;        W[V4      p\=        VVVP?                  4       4       VPA                  VPB                  4       \/        VPD                  \1        4       V\F        PH                  R7      p\K        4       p\M        VRV4       \M        VRV4       \M        VRV4       \M        VRR4       V PO                  V
VVV4       V PQ                  V
VV4       V'       d   V PS                  V
VV4       V
P                  R4       V PU                  V4       V'       d   \W        V
V4       \Y        WbV4      p\[        WûRVVRV: RV: R24       \]        W¯V4       \"        P$                  ! V4       R # )NrÑ   z"New realm for backed up domain: %sz$New base DN for backed up domain: %szNew domain NetBIOS name: %srÒ   rÔ   )r?   rM   rL   r“   rÕ   rV   rh   rÖ   z+Cannot use the current domain NetBIOS name.z(Cannot use the current domain DNS realm.r×   rØ   rÜ   rÝ   rß   rà   rA  rá   rH  z$Fixing DN attributes after rename...zOriginal domain rŒ   z (DNS realm))/rã   rä   rå   ÚINFOrç   rè   r   r¥   r‘   r  r¯   r—  r4   ré   rê   r   rŒ  rí   rî   r�   Údo_joinÚlocal_samdbrë   r   r   rI   re   rf   rg   rZ   r   r5   rP   rŸ  r>   r8   rï   rc   r    rÄ  rÐ  rÕ  rØ  r¶   rl   r•   r‡   )rð   r´  rµ  r¹   rº   rV   rh   Úkeep_dns_realmrñ   rÖ   r?   rL   rM   r¾  Únew_base_dnr…   r“   ró   Ú
old_domainr½  rë   rô   rõ   rö   r÷   r>   rj   rø   s   &&&&&&&&&&                  rH   rù   Úcmd_domain_backup_rename.runX  sß  € ð —‘Ó"ˆØ�‰œŸ™Ô%à×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆð Š>ÜÐ0Ó1Ð1ä˜Ô*à+Ô+ˆà%×+Ñ+Ó-ˆØ)×/Ñ/Ó1ˆä×,Ò,¨]Ó;ˆØ�‰Ð8¸=ÕHÔIØ�‰Ð:¸[ÕHÔIØ�‰Ð1°OÕCÔDä×!Ò! iÔ0ˆð )œ.ˆÜ% kØ&3Ø,1Ø6EØ2BØ-3Ø4AôCˆð —_‘_ˆ
Ø˜Ô(Ü�MŠM˜&Ô!ÜÐLÓMÐMà—I‘Iˆ	Ø˜Ô%Ü�MŠM˜&Ô!ÜÐIÓJÐJð 	�‰Œð ˆOØ—	‘	ˆô ˜y¨6Õ1¸uÜ(6Ó(8¸RôAˆ
ä% j°&Ó9ˆô —W‘W—\‘\ &¨/Ó:ˆ
Ü" 6¨uÓ5ˆÜ�h 
¨J×,EÑ,EÓ,GÔHð 	�‰�—‘ÔÜ˜%Ÿ+™+´NÓ4DÈÜ×2Ñ2ô4ˆô !“?ˆÜ˜% ¨xÔ8Ü˜% °'Ô:Ü˜% °Ô;Ü˜% ¨xÔ8ð 	×Ñ˜V U¨I°~ÔFð 	×$Ñ$ V¨U°OÔDçØ×%Ñ% f¨e°YÔ?à�‰Ð:Ô;Ø×"Ñ" 5Ô)÷ Ü˜v uÔ-ô & iÀÓIˆÜ˜ H¨f±oã#£Yð0ô	1ô 	˜&¨+Ô6ä�Š�fÖr[   rb   )NNNNFFN)rû   rü   rý   rþ   rÿ   r   r  r  r  r  r   r6   r   r  Ú
takes_argsrÄ  rÐ  rÕ  rØ  rù   r  r  r  s   @rH   r³  r³  È  sÐ   ø‡ € ñð8+€Hð 	�W×)Ñ)Ø�G×.Ñ.ðÐñ 	ˆzÐ 2¸Ô=Ùˆ}Ð#GØô	áÐ!¨,ÀØLô	Náˆ~ l¸EØCô	EáÐ  x¸Ø˜u�~ð!Ù#<Ó#>õ?ô	@ð€Mð $ _Ð5€Jò#(òN>ò4,ò#÷gò gr[   r³  c                   óˆ   a € ] tR tRt o RtRtR]P                  /t]	! RR]
R7      .tRtR	 tR
 tR tR tR tRR ltRtV tR# )Úcmd_domain_backup_offlineiÂ  ay  Backup the local domain directories safely into a tar file.

Takes a backup copy of the current domain from the local files on disk,
with proper locking of the DB to ensure consistency. If the domain were to
undergo a catastrophic failure, then the backup file can be used to recover
the domain.

An offline backup differs to an online backup in the following ways:
- a backup can be created even if the DC isn't currently running.
- includes non-replicated attributes that an online backup wouldn't store.
- takes a copy of the raw database files, which has the risk that any
  hidden problems in the DB are preserved in the backup.z%prog [options]r¹   rÀ   zOutput directory (required)r½   z.bak-offlinec                ó  € WP                   ,           p \        WR R7       \        P                  P                  T4      '       g   Rp\        TP                  T4      4      hR#   \         do   p \        P                  ! T4       Th  \
         dC   p\        TR4      '       d*   TP                  \        P                  8X  d    Rp? Rp?R# ThRp?ii ; iRp?i\         d   p\        TP                  T4      hRp?ii ; i)T)ÚreadonlyÚerrnoNz1tdbbackup said backup succeeded but {0} not found)Ú
backup_extr#   r%   rÊ   rw   Ú	ExceptionÚhasattrrç  ÚEINVALÚFileNotFoundErrorr   Ústrerrorre   rf   r¢   r9  )rð   rf   Úbackup_pathÚcopy_errrE   Úss   &&    rH   Úoffline_tdb_copyÚ*cmd_domain_backup_offline.offline_tdb_copyÝ  sÌ   € ØŸ_™_Õ,ˆð	.Ü�T°Õ6ô" �w‰w�~‰~˜k×*Ò*ØCˆAÜ˜qŸx™x¨Ó4Ó5Ð5ñ +øô! "ô 
	ðÜ—’˜”ð
 ˆNøô	 ô Ü˜1˜g×&Ò&¨1¯7©7´e·l±lÔ+Bß‘FØ�ûðþô !ô 	.ä˜qŸz™z¨1Ó-Ð-ûð	.úsS   ”A$ Á$DÁ0BÂCÂCÂ1CÃCÃCÃCÃCÃDÃ%DÃ&C<Ã<Dc                ó>   € \        WV P                  ,           4       R # ©N)r$   rè  )rð   rf   s   &&rH   Úoffline_mdb_copyÚ*cmd_domain_backup_offline.offline_mdb_copyö  s   € Ü�˜dŸo™oÕ-Ö.r[   c                ó\  € \         P                  P                  VR 4      p\        VR,           V\        P
                  R7      pVP                  RV,           4       VP                  4        V P                  VR,           4       V P                  VR,           4       VP                  4        R# )Úsecretsú.ldb©rL   rÞ   úStarting transaction on ú.tdbN)
re   rf   rg   r   r8   rï   r4   r/  rñ  Útransaction_cancel)rð   r¡  rL   r?   rª  Úsecrets_objs   &&&&  rH   Úbackup_secretsÚ(cmd_domain_backup_offline.backup_secretsû  s‚   € Ü—w‘w—|‘| K°Ó;ˆÜ˜,¨Õ/°BÜ #× 6Ñ 6ô8ˆà�‰Ð.°Õ=Ô>Ø×%Ñ%Ô'Ø×Ñ˜l¨VÕ3Ô4Ø×Ñ˜l¨VÕ3Ô4Ø×&Ñ&Ö(r[   c                ót  € \         P                  P                  VR 4      pRpVP                  R\        P
                  V.R7      pWg^ ,          9   ;'       d$    \        V^ ,          V,          ^ ,          4      R8H  pRp	Rp
V'       d/   VP                  R4       V P                  p
VP                  4       p	M4VP                  RV,           4       V P                  p
VP                  4        VP                  RV,           4       V P                  V4       VR	,           p\         P                  ! V4       FÜ  p\         P                  P                  W¼4      pVP                  R
4      '       d#   VP                  RV,           4       V
! V4       K[  VP                  R4      '       d,   VP                  RV,           4       V P                  V4       K�  VP                  RV,           4       \        P                  ! WÌV P                   ,           4       KÞ  	  \#        W$4      pV'       d   ?	V# VP%                  4        V# )r`  ÚbackendStorez
@PARTITIONr@  rË   Nz1MDB backend detected.  Using mdb backup function.rû  z   backing up z.drù  z"   backing up locked/related file rü  z$   tdbbackup of locked/related file z   copying locked/related file )re   rf   rg   r7   r8   r9   r6   r4   rõ  Úsearch_iteratorrñ  r/  rx  Úendswithrí   rƒ  rè  rI   rý  )rð   r¡  r>   rL   r?   Úsam_ldb_pathÚstore_labelrD   Úmdb_backendÚres_iteratorÚcopy_functionÚ	sam_ldb_dÚsam_filerB   s   &&&&&         rH   Úbackup_smb_dbsÚ(cmd_domain_backup_offline.backup_smb_dbs
  sÇ  € Ü—w‘w—|‘| K°Ó;ˆð %ˆØ�l‰l ´C·N±NØ"- ð ó 0ˆà!¨¥VÑ+×TÐT´°C¸µF¸;Õ4GÈÕ4JÓ0KÈuÑ0Tˆð ˆàˆßØ�K‰KÐKÔLØ ×1Ñ1ˆMð !×0Ñ0Ó2‰Là�K‰KÐ2°\ÕAÔBØ ×1Ñ1ˆMØ×#Ñ#Ô%à�‰Ð$ |Õ3Ô4Ø×Ñ˜lÔ+Ø  4Õ'ˆ	ÜŸ
š
 9Ö-ˆHÜ—w‘w—|‘| IÓ8ˆHØ× Ñ  ×(Ò(Ø—‘Ð@À8ÕKÔLÙ˜hÖ'Ø×"Ñ" 6×*Ò*Ø—‘ÐBÀXÕMÔNØ×%Ñ% hÖ/à—‘Ð=ÀÕHÔIÜ—’ °T·_±_Õ*DÖEñ .ô " %Ó0ˆçàð ˆ
ð ×$Ñ$Ô&àˆ
r[   c                ó�  € R VP                   RVP                  R\        P                  P	                  VP
                  4      /pVP                  4        UUu. uF!  w  rEVP                  V4      '       g   K  WE3NK#  	  pppV^ ,          w  rx\        V4      ^8”  d   \        VR R7      w  rxWq\        V4      R ,          pV# u uppi )r_  Ústater^  c                 ó&   € \        V ^,          4      # )é   )r:   )Úps   &rH   rs   Ú8cmd_domain_backup_offline.get_arc_path.<locals>.<lambda>P  s   € ÄÀQÀqÅTÄr[   )ÚkeyN)
r¡  Ú	state_dirre   rf   ÚdirnamerŸ  ÚitemsÚ
startswithr:   Úmax)	rð   rf   Ú
conf_pathsÚbackup_dirsr¨  r  Úmatching_dirsÚarc_pathÚfs_paths	   &&&      rH   Úget_arc_pathÚ&cmd_domain_backup_offline.get_arc_pathE  s»   € Ø  *×"8Ñ"8Ø 
× 4Ñ 4ØœbŸg™gŸo™o¨j×.@Ñ.@ÓAðCˆð /:×.?Ñ.?Ô.Aô -Ñ.A¡F QØŸ™¨×+ô  ˜!›Ñ.Aˆñ -à)¨!Õ,Ñˆô ˆ}Ó Ô!Ü # MÑ7JÔ KÑˆHØœ˜W›˜Ð'Õ'ˆàˆùó-s   ÁCÁ7CNc           	     óÀ  € \         P                  ! 4       pVP                  \         P                  4       VP	                  \         P
                  ! \        P                  4      4       VP                  4       p\        P                  P                  WDP                  R 4      4      pVP                  '       d0   \        P                  P!                  VP                  4      '       g6   VP#                  RP%                  VP                  4      4       \'        R-4      h\)        W24       VP*                  VP,                  \        P                  P/                  VP0                  4      .pVP3                  RP%                  RP5                  V4      4      4       . p\7        4       pV EF”  p	\        P8                  ! V	4       EFu  w  r«pV
P;                  VP<                  4      '       d   K*  V
P?                  R4      '       g   RV
9   d   KJ  V
P;                  \        P                  P5                  VP@                  R4      4      '       d   K‹  V Fä  p\        P                  P5                  W­4      p \        PB                  ! VRR7      pTPH                  TPJ                  3T9   d   KZ  TP?                  T PL                  4      '       d   \        PN                  ! T4       K“  TP?                  R4      '       d   K¬  TPQ                  T4       TPS                  TPH                  TPJ                  34       Kæ  	  EKx  	  EK—  	  \U        VP                  \W        4       V\X        PZ                  R
7      pV P]                  VP*                  WC4       V P_                  VP*                  VWC4      pVPa                  4       p\b        Pd                  ! V4      pVPg                  4        ?\i        VP                  V PL                  ,           \W        4       VR.\X        PZ                  R7      p\k        4       p\m        VRV4       \m        VRV4       \m        VRR4       VPg                  4        ?V EF  p\        P                  P!                  VV PL                  ,           4      '       d   K<  VP?                  R4      '       dy   VP3                  RV,           4       \i        VV\X        PZ                  R7      pVPo                  4        VP3                  R4       V Pq                  V4       VPs                  4        KË  VP?                  R4      '       g   Kä  VP3                  RV,           4       V Pq                  V4       EK  	  \t        Pv                  ! VRR7      p\        P                  P5                  VR4      p\x        Pz                  ! VR4      pVP3                  R4       Rp\        P                  P5                  VV4      p\}        VP<                  VVP0                  V4       VPS                  VV4       \        PN                  ! V4       \        VVRRR4       \        P                  P5                  VR4      pVPS                  V\        P                  P�                  V4      4       \        PN                  ! V4       VP3                  R 4       . pV EF¸  pV Pƒ                  VV4      p\        P                  P!                  VV PL                  ,           4      '       d°   VP3                  R!V,           V PL                  ,           R",           4       VPQ                  \…        VV PL                  ,           4      : R#V: 24       VPS                  VV PL                  ,           VR$7       \        PN                  ! VV PL                  ,           4       Kû  VP?                  R4      '       g   VP?                  R4      '       d   VP3                  R%V,           4       EKD  \        P                  P‡                  V4      '       g   EKl  VP3                  R&V,           4       VPQ                  \…        V4      : R#V: 24       VPS                  VVR$7       EK»  	  \        P                  P5                  VR'4      p\{        VR(4      ;_uu_ 4       p V F  p!V P‰                  V!R),           4       K  	  R*R*R*4       VPS                  V\        P                  P�                  V4      4       \        PN                  ! V4       VP‹                  4        \        PŒ                  ! V\        P                  P5                  VR+P%                  V4      4      4       \        PŽ                  ! V4       VP3                  R,4       R*#   \D         d    TPG                  T R	24        EK~  i ; i  + '       g   i     Lù; i).r�   zNo database found at {0}zrunning backup on dirs: {0}Ú z.sockz.sock/ÚdnsF)Úfollow_symlinksz does not exist!rÝ   zmodules:)rÙ   rÛ   rL   r  rÞ   rß   rà   rá   rc  rù  z!Starting transaction on solo db: rú  z%   running tdbbackup on the same filerü  z#running tdbbackup on lone tdb file ÚINCOMPLETEsambabackupfile)rÓ   Úprefixzsamba-backup.tar.bz2r   z&running offline ntacl backup of sysvolrÜ   Ú	localhostTr‰   zbuilding backup tarz   adding backup z to tar and deleting filez  r€   z   skipping z   adding misc file Ú	SHA256SUMrŠ   Ú
Nzsamba-backup-{0}.tar.bz2zBackup succeeded.zCPlease check you are root, and are running this command on an AD DC)Hrå   rz  rä   ræ   r{  r|  r}  r~  rç   r¯   Ú	provisionÚprovision_paths_from_lpr�   r>   re   rf   r¢   r‘  r9  r   r¥   r¡  r  r  rŸ  r4   rg   ÚsetÚwalkr  rK   r  Úbinddns_dirÚstatrì  r�  Úst_inoÚst_devrè  rœ  Úappendrƒ   r   r   r8   rï   rÿ  r  r5   r   r   Ú
disconnectr   rc   r    r/  rñ  rý  ré   rê   r‚   rw   r
   r•   Úbasenamer  r}   r›  r�   r„   rH  Úrmdir)"rð   r¹   rh   r?   rL   rë   r  Ú	all_filesÚ	all_statsÚ
backup_dirÚworking_dirr¨  Ú	filenamesrk   Ú	full_pathrð  r>   rB   Údom_sid_strr   rj   rf   Úldb_objÚtemp_tar_dirÚtemp_tar_nameÚtarÚsysvol_tar_fnrö   Ú	backup_fnÚchksum_listr  Úchksum_filepathrr   Úcs"   &&&                               rH   rù   Úcmd_domain_backup_offline.runU  s   € ä×"Ò"Ó$ˆØ�‰œŸ™Ô&Ø×Ñœ'×/Ò/´·
±
Ó;Ô<ð ×#Ñ#Ó%ˆä—‘×7Ñ7¸¿F¹FÀ7»OÓLˆØ——�¤§¡§¡¨u¯{©{× ;Ò ;Ø�L‰LÐ3×:Ñ:¸5¿;¹;ÓGÔHÜð  Fó Gð Gô 	˜Ô*ð ×(Ñ(¨%¯/©/Ü—w‘w—‘ u§}¡}Ó5ð7ˆà�‰Ð1×8Ñ8¸¿¹À+Ó9NÓOÔPð ˆ	Ü“Eˆ	Ü%ˆJÜ/1¯wªw°z×/BÑ+� Ø×)Ñ)¨%¯,©,×7Ò7ÙØ×'Ñ'¨×0Ò0°HÀÔ4KÙð ×)Ñ)¬"¯'©'¯,©,°u×7HÑ7HÈ%Ó*P×QÒQÙã )�HÜ "§¡§¡¨[Ó C�Ið
!ÜŸGšG I¸uÔE˜ð
 Ÿ™ !§(¡(Ð+¨yÔ8Ù ð  ×(Ñ(¨¯©×9Ò9ÜŸ	š	 )Ô,Ù ð  ×(Ñ(¨×1Ò1Ù à×$Ñ$ YÔ/Ø—M‘M 1§8¡8¨Q¯X©XÐ"6Ö7ô5 !*ô 0Cñ &ôT ˜%Ÿ+™+´NÓ4DÈÜ×2Ñ2ô4ˆð 	×Ñ˜E×-Ñ-¨rÔ:Ø×!Ñ! %×"3Ñ"3°U¸BÓGˆð ×*Ñ*Ó,ˆÜ×"Ò" ;Ó/ˆð
 	×ÑÔØô ˜Ÿ™ d§o¡oÕ5Ü#1Ó#3¸Ø)˜l´#×2HÑ2HôJˆô !“?ˆÜ˜% ¨xÔ8Ü˜% °#Ô6Ü˜% ¨yÔ9ð 	×ÑÔØô ˆDÜ—7‘7—>‘> $¨¯©Õ"8×9Ô9Ø—=‘= ×(Ò(Ø—K‘KÐ CÀdÕ JÔKÜ! $¨2´S×5KÑ5KÔL�GØ×-Ñ-Ô/Ø—K‘KÐ GÔHØ×)Ñ)¨$Ô/Ø×.Ñ.Ö0Ø—]‘] 6×*Ô*Ø—K‘KÐ EÈÕ LÔMØ×)Ñ)¨$×/ñ ô  ×'Ò'¨IØ/JôLˆäŸ™Ÿ™ \Ð3IÓJˆÜ�lŠl˜=¨'Ó2ˆà�‰Ð<Ô=Ø'ˆÜ—W‘W—\‘\ ,°Ó>ˆ
Ü�u—|‘| Z°·±ÀÔHØ�‰�
˜MÔ*Ü
�	Š	�*Ôä˜ b¨)°[À$ÔGÜ—G‘G—L‘L ¨|Ó<ˆ	Ø�‰�	œ2Ÿ7™7×+Ñ+¨IÓ6Ô7Ü
�	Š	�)Ôà�‰Ð)Ô*àˆäˆDØ×(Ñ(¨¨uÓ5ˆHä�w‰w�~‰~˜d T§_¡_Õ4×5Ò5Ø—‘Ð/°(Õ:¸T¿_¹_ÕLØ7õ8ô 9à×"Ñ"Ü 0°¸¿¹Õ1GÖ HÚ (ð*ô+ð —‘˜˜tŸ™Õ.¸�ÔAÜ—	’	˜$ §¡Õ0Ö1Ø—‘˜v×&Ò&¨$¯-©-¸×*?Ò*?Ø—‘˜N¨XÕ5×6Ü—‘—‘ ×%Õ%Ø—‘Ð2°XÕ=Ô>Ø×"Ñ"Ü$4°TÖ$:Ú$,ð$.ô /ð —‘˜ h�×/ñ% ô( Ÿ'™'Ÿ,™, |°[ÓAˆÜ�/ 3×'Ô'¨1Û �Ø—‘˜˜D�Ö!ñ !÷ (ð 	�‰�¤§¡×!1Ñ!1°/Ó!BÔCÜ
�	Š	�/Ô"à�	‰	ŒÜ
�	Š	�-Ü—'‘'—,‘,˜yØ9×@Ñ@ÀÓJóLô	Mô 	�Š�ÔØ�‰Ð'Ö(øôA -ô !ØŸ™¨)¨Ð4DÐ'EÔFÛ ð!ú÷j (×'ús   É.f&â:"gæ&g
	ç	g
	çg	rb   )NN)rû   rü   rý   rþ   rÿ   r   r  r  r  r   r6   r  rè  rñ  rõ  rÿ  r  r  rù   r  r  r  s   @rH   rä  rä  Â  sk   ø‡ € ñ@ð !€Hà�W×)Ñ)ðÐñ
 	ˆ}Ø1Øô	ð€Mð  €Jò6ò2/ò
)ò8òv÷ o)ò o)r[   rä  c            	       óV   € ] tR tRtRtR]! 4       R]! 4       R]! 4       R]! 4       /t	Rt
R# )	Úcmd_domain_backupi  z)Create or restore a backup of the domain.rc  râ   rH  Úrestorerb   N)rû   rü   rý   rþ   rÿ   rä  r¸   r³  r  Úsubcommandsr  rb   r[   rH   rH  rH    s0   † Ù3ØÑ7Ó9ØÑ5Ó7ØÑ5Ó7ØÑ7Ó9ð;„Kr[   rH  rô  )`r^   re   r}  rå   rí   ré   r¯   rÊ   Úsamba.getoptÚgetoptr  Úsamba.samdbr   r   r8   r   Úsamba.samba3r   rT   r   rN   Úsamba.ntaclsr   r	   r
   Ú
samba.authr   Ú
samba.joinr   r   r   Úsamba.dcerpc.securityr   Úsamba.netcmdr   r   Úsamba.dcerpcr   r   r   r   Úsamba.netcmd.fsmor   Úsamba.provisionr   r   Úsamba.upgradehelpersr   Úsamba.remove_dcr   r   Úsamba.dbcheckerr   r»  r   r   r   Úsamba.provision.sambadnsr    r!   r"   Úsamba.tdb_utilr#   Úsamba.mdb_utilr$   rç  Ú
subprocessr%   r&   Ú
samba.dsdbr'   Ú	samba.ndrr(   Úsamba.credentialsr)   r*   r‚   ru   rI   rZ   rc   rl   r}   r‡   r•   r    r¥   r¶   ÚnetcmdÚCommandr¸   r  r³  rä  ÚSuperCommandrH  rb   r[   rH   Ú<module>rd     s9  ðó$ Û 	Û 
Û Û Û Û Û 
Ý ß 8Û 
Ý Ý 8Ý )ß FÑ FÝ %ß IÑ IÝ )ß -ß 1Ñ 1Ý Ý ,ß 5Ý ?Ý %Ý /Ý #Û 	ß NÑ N÷6ñ 6õ $Ý #Û Ý )Ý Ý (Ý Ý 2Ý )Û ò-%ò`òAò-ò
òôò,ò@ò)ô,c"˜uŸ|™|×3Ñ3ô c"ôLF' ô F'ôRw˜uŸ|™|×3Ñ3ô wôtB) §¡× 4Ñ 4ô B)ôJ
;˜Ÿ™×1Ñ1ö ;r[   