{"id":1139,"date":"2022-03-11T14:37:48","date_gmt":"2022-03-11T17:37:48","guid":{"rendered":"https:\/\/gladiston.net.br\/?page_id=1139"},"modified":"2022-09-14T10:58:58","modified_gmt":"2022-09-14T13:58:58","slug":"como-fazer-backup-e-ou-transferencia-das-contas-de-usuarios","status":"publish","type":"page","link":"https:\/\/gladiston.net.br\/en\/banco-de-dados\/como-fazer-backup-e-ou-transferencia-das-contas-de-usuarios\/","title":{"rendered":"How to backup and\/or transfer user accounts"},"content":{"rendered":"<p>This article is more about transferring active user accounts on a server to a workstation, however, the same principle applies to a backup of user accounts. Why do?<\/p>\n\n\n\n<p>With the user accounts on our workstation we can change all of their real passwords to say, <strong>masterkey<\/strong> and working with them and testing real permission environments on tables, triggers, procedures and any other objects we have to GRANT. In addition, we can have the backup of the accounts, just in case of an accident and need to recover it again.<\/p>\n\n\n\n<p>Another real scenario is when we are migrating from, for example, FirebirdSQL3 to FirebirdSQL4. Our following example will be based on this scenario.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">BACKUP USER ACCOUNTS IN PRODUCTION<\/h2>\n\n\n\n<p>To run the backup of \u201csecurity3.fdb\u201d you need to be using the administrator account and open the terminal with it, then you can access the FirebirdSQL folder which is protected by administrative permissions and then run:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">set path=%path%;&quot;C:\\Program Files\\Firebird\\Firebird_3_0&quot;\ngbak -v -b -t -user sysdba &quot;C:\\Program Files\\Firebird\\Firebird_3_0\\security3.fdb&quot; c:\\temp\\security3.fbk<\/pre><\/div>\n\n\n\n<p>In the example above, we made the backup. If this is your goal, now just keep the file \u201cc:\\temp\\security3.fbk\u201d in a safe place. Note in the example above that we didn&#039;t use gbak&#039;s -password PRODUCT PASSWORD parameter, why not? It is not necessary because the access in this case is embedded.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">RESTORING THE BACKUP OF USER ACCOUNTS<\/h2>\n\n\n\n<p>Either for any of the scenarios I mentioned at the beginning, to restore the database we will need the <strong>gbak<\/strong> of the desired version and obviously from the backup file:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">set path=%path%;&quot;C:\\Program Files\\Firebird\\Firebird_3_0&quot;\ncd &quot;C:\\Program Files\\Firebird\\Firebird_3_0&quot;\nren security3.fdb security3.fdb.ori\ngbak -v -r -user sysdba c:\\temp\\security3.fbk &quot;C:\\Program Files\\Firebird\\Firebird_3_0\\security3.fdb&quot;<\/pre><\/div>\n\n\n\n<p>Backup of user accounts has been restored!<\/p>\n\n\n\n<p>IMPORTANT: If you are bringing production user accounts to the development environment you will need to change the SYSDBA password for security reasons, imagine the catastrophe that would be for you to enter the production base thinking you are entering the development base.<\/p>\n\n\n\n<p>CHANGING SYSDBA PASSWORD<\/p>\n\n\n\n<p>As of now, you have restored user accounts but want to change SYSDBA password, how to do? It&#039;s simple, first we&#039;ll need to connect to the security3.fdb base: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">set path=%path%;&quot;C:\\Program Files\\Firebird\\Firebird_3_0&quot;\nisql.exe -user SYSDBA &quot;C:\\Program Files\\Firebird\\Firebird_3_0\\security3.fdb&quot;\n<\/pre><\/div>\n\n\n\n<p>Then we will execute this sequence of commands changing not only the SYSDBA user&#039;s password, but if it is in a development environment, also yours and the users who want to simulate an action within the database:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">alter user SYSDBA password 'masterkey';\n-- altere outras senhas se preferir, por exemplo, equipe de desenvolvimento:\n-- afinal, n\u00e3o \u00e9 bom que a equipe de desenvolvimento tenham as mesmas senhas\n-- em produ\u00e7\u00e3o e tamb\u00e9m desenvolvimento:\nalter user MINHACONTA password 'masterkey';\nalter user DEV_USER1 password 'masterkey';\nalter user DEV_USER2 password 'masterkey';\ncommit;\nquit;\n<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">RESTORING ACCOUNT BACKUP IN FIREBIRD 4<\/h2>\n\n\n\n<p>The restore procedure is basically the same, what differs is the directory of FB4 which is different from FB3:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">set path=%path%;&quot;C:\\Program Files\\Firebird\\Firebird_4_0&quot;\ncd &quot;C:\\Program Files\\Firebird\\Firebird_4_0&quot;\nren security4.fdb security4.fdb.ori\ngbak -v -r -user sysdba c:\\temp\\security3.fbk &quot;C:\\Program Files\\Firebird\\Firebird_4_0\\security4.fdb&quot;<\/pre><\/div>\n\n\n\n<p>The above principle will work for any database upgrade.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">GOOD PRACTICES WITH BACKUP\/RESTORE<\/h2>\n\n\n\n<p>It is imperative that you NEVER mix development passwords with production passwords, whether in one bank or the other. When it is necessary to bring a base to the development environment, the first thing to do is change the passwords contained therein.<\/p>\n\n\n\n<p>Don&#039;t use the -rep option to restore a backup over the existing database, be cautious, do as I showed above, rename the old file to .bak and proceed with your restore.<\/p>\n\n\n\n<p>The server is not \u201cMaria Joana&#039;s house\u201d, inexperienced people should not have access to the administrator account or any production server, so the backup\/restore procedure must be performed by someone experienced, perhaps pragmatic when the situation is to do things with caution and dexterity.<\/p>","protected":false},"excerpt":{"rendered":"<p>Este artigo foi pensado mais em transferir as contas de usu\u00e1rios ativos num servidor para uma esta\u00e7\u00e3o de trabalho, no entanto, o mesmo principio de aplica a um backup das contas de usu\u00e1rios. Por que fazer? Com as contas de usu\u00e1rios em nossa esta\u00e7\u00e3o de trabalho podemos alterar todas as senhas reais deles para digamos, [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":1109,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"templates\/template-full-width.php","meta":{"footnotes":""},"class_list":["post-1139","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/1139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/comments?post=1139"}],"version-history":[{"count":2,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/1139\/revisions"}],"predecessor-version":[{"id":2031,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/1139\/revisions\/2031"}],"up":[{"embeddable":true,"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/pages\/1109"}],"wp:attachment":[{"href":"https:\/\/gladiston.net.br\/en\/wp-json\/wp\/v2\/media?parent=1139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}