Home
%3CLINGO-SUB%20id%3D%22lingo-sub-772655%22%20slang%3D%22en-US%22%3EPoint%20in%20Time%20Restore%20in%20Azure%20database%20for%20MySQL%20and%20Azure%20Database%20for%20PostgreSQL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-772655%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EOften%2C%20users%20are%20reporting%20point%20in%20time%20restores%20are%20showing%20recent(current)%20data%20in%20the%20restored%20server.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESolution%3A%20When%20you%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Erun%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Epoint%20in%20time%20restore%20(PITR)%20this%20operation%20will%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ecreate%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Ba%20new%20server%20and%20restor%3C%2FSPAN%3E%3CSPAN%3Ee%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Byour%20server%20to%20a%20point%20of%20time%20that%20you%20choose.%20When%20the%20restore%20operation%20is%20successful%26nbsp%3Bplease%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eremember%20that%20you%20need%20to%20update%20the%20connection%20string%20to%20connect%20to%20the%20newly%20created%20server%20in%20%3CSTRONG%3Etwo%20places%3C%2FSTRONG%3E%2C%20server%20name%20and%20username.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIt's%26nbsp%3Bimportant%20to%20change%20the%20%3CSTRONG%3Eusername%3C%2FSTRONG%3Ein%20the%20new%20connection%20string%20to%20reflect%20the%20new%20server%20name.%20I%3C%2FSPAN%3E%3CSPAN%3En%20Azure%20Database%20for%20MySQL%20and%20Azure%20Database%26nbsp%3Bfor%20PostgreSQL%20usernames%20consists%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eof%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Etwo%20parts%20separated%20by%20the%20'%3CSTRONG%3E%40%3C%2FSTRONG%3E'%20symbol%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ein%20the%20following%20format%3A%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eusername%40servername.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3ENow%26nbsp%3Bwhen%26nbsp%3Byou%20connect%20to%20the%20database%20server%20and%20if%20you%20see%20the%20data%20as%20in%20current%20this%20means%20that%20your%20connection%20string%20has%20the%20server%20name%20correct%20but%20the%20username%20part%20is%20still%20set%20to%20the%20original%20(source)%20server%20name%20as%20the%20following%20%22%3CFONT%20color%3D%22%23FF0000%22%3Esource-server-db.%3C%2FFONT%3Emysql.database.azure.com%22%20which%20is%20incorrect%2C%20alternatively%20set%20it%26nbsp%3B%20here%20also%20to%20connect%20to%20the%20newly%20created%20server.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EExample%3A%20If%20i%20need%20to%20restore%20server%20%22source-server-%3C%2FSPAN%3E%3CSPAN%3Edb%3C%2FSPAN%3E%3CSPAN%3E%22%20point%20in%20time%205%20days%20ago%2C%20I%20will%20go%20to%20the%20portal%20and%20navigate%20to%20the%20restore%20blade%20and%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eset%20the%20restored%20server%20to%20be%20called%20%22%3C%2FSPAN%3E%3CSPAN%3Edestination-server-db%3C%2FSPAN%3E%3CSPAN%3E%22%2C%20as%20in%20the%20following%20screenshot%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124390i44F27211ACFADB99%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22restore%20OSS%20server.png%22%20title%3D%22restore%20OSS%20server.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EAfter%20the%20restore%20operation%20is%20successful%20and%20when%20you%20want%20to%20connect%20to%20the%20database%26nbsp%3Byou%20will%20need%20to%20use%20the%20following%20connection%20string%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3Eserver%3A%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Edestination-server-%3C%2FSTRONG%3E%3CSPAN%3E%3CSTRONG%3Edb%3C%2FSTRONG%3E.mysql.database.azure.com%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3Eusername%3A%26nbsp%3Bbahusse%40%3CSTRONG%3Edestination-server-db%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENow%20why%20this%20happens%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EIn%20Azure%20Database%20for%20MySQL%20and%20azure%20database%26nbsp%3Bfor%20PostgreSQL%2C%20each%20region%20shares%20a%20common%20endpoints%20or%20gateway%20to%20start%20your%20connection%20process.%26nbsp%3B%20When%20your%20connection%20is%20initially%20started%2C%20it%20will%20resolve%20your%20full%20server%20name%2C%20in%20this%20case%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Edestination-server-%3C%2FSPAN%3E%3CSPAN%3Edb.mysql.database.azure.com.%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BThis%20gateway%20is%20then%20able%20to%20review%20the%20connection%20details%20to%20determine%20the%20specifics%20of%20your%20server%20and%20where%20it%20resides%20in%20that%20region.%26nbsp%3B%20It%20will%20then%20provide%20that%20information%20to%20the%20client%20to%20proceed%20to%20connect%20to%20your%20specific%20instance.%26nbsp%3B%20In%20a%20scenario%20such%20as%20with%20MySQL%20Workbench%20or%20PgAdmin%20or%20any%20other%20client%3C%2FSPAN%3E%3CSPAN%3E%2C%20this%20is%20determined%20by%20looking%20at%20the%20user%20name%20and%20then%20if%20necessary%2C%20the%20server%20name.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EAs%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ethe%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eusername%20in%20the%20above%20example%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Bis%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eusername%40%3C%2FSPAN%3E%3CSPAN%3Edestination-server-%3C%2FSPAN%3E%3CSPAN%3Edb%3C%2FSPAN%3E%3CSPAN%3E%2C%20it%20will%20initially%20speak%20to%20the%20gateway%20which%20is%20resolved%20from%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Edestination-server-%3C%2FSPAN%3E%3CSPAN%3Edb.mysql.database.azure.com%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3Band%20ask%20for%20the%20details%20of%20mydomain.com%20as%20that%20is%20part%20of%20the%20user%20name%20provided%20after%20the%20%40%20symbol.%26nbsp%3B%20By%20adding%20the%20%40server%20to%20the%20end%20of%20my%20overall%20user%2C%20it%20is%20able%20to%20essentially%20'override'%20what%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eclient%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ethinks%20is%20the%20server%20provided%20in%20the%20user%20name%20by%20explicitly%20stating%20the%20server%20as%20well.%20You%20will%20notice%20that%26nbsp%3Ball%26nbsp%3Bthe%20provided%26nbsp%3Bconnection%20strings%20in%20the%20portal%20for%20a%26nbsp%3Bserver%26nbsp%3Buse%20the%20user%40server%20syntax%20by%20default%20for%20the%20user%20due%20this%20same%20of%20behavior.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EReference%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fazuresqldbsupport%2F2017%2F09%2F12%2Fproviding-the-server-name-explicitly-in-user-names-for-azure-sql-db%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblogs.msdn.microsoft.com%2Fazuresqldbsupport%2F2017%2F09%2F12%2Fproviding-the-server-name-explicitly-in-user-names-for-azure-sql-db%2F%3C%2FA%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Microsoft

Often, users are reporting point in time restores are showing recent(current) data in the restored server.

 

Solution: When you run point in time restore (PITR) this operation will create a new server and restore your server to a point of time that you choose. When the restore operation is successful please remember that you need to update the connection string to connect to the newly created server in two places, server name and username.

 

It's important to change the username in the new connection string to reflect the new server name. In Azure Database for MySQL and Azure Database for PostgreSQL usernames consists of two parts separated by the '@' symbol in the following format: username@servername.

 
Now when you connect to the database server and if you see the data as in current this means that your connection string has the server name correct but the username part is still set to the original (source) server name as the following "source-server-db.mysql.database.azure.com" which is incorrect, alternatively set it  here also to connect to the newly created server.
 
Example: If i need to restore server "source-server-db" point in time 5 days ago, I will go to the portal and navigate to the restore blade and set the restored server to be called "destination-server-db", as in the following screenshot:
restore OSS server.png
 
After the restore operation is successful and when you want to connect to the database you will need to use the following connection string
 
server: destination-server-db.mysql.database.azure.com
username: bahusse@destination-server-db



Now why this happens? 

In Azure Database for MySQL and azure database for PostgreSQL, each region shares a common endpoints or gateway to start your connection process.  When your connection is initially started, it will resolve your full server name, in this case, destination-server-db.mysql.database.azure.com. This gateway is then able to review the connection details to determine the specifics of your server and where it resides in that region.  It will then provide that information to the client to proceed to connect to your specific instance.  In a scenario such as with MySQL Workbench or PgAdmin or any other client, this is determined by looking at the user name and then if necessary, the server name.
As the username in the above example is username@destination-server-db, it will initially speak to the gateway which is resolved from destination-server-db.mysql.database.azure.com and ask for the details of mydomain.com as that is part of the user name provided after the @ symbol.  By adding the @server to the end of my overall user, it is able to essentially 'override' what client thinks is the server provided in the user name by explicitly stating the server as well. You will notice that all the provided connection strings in the portal for a server use the user@server syntax by default for the user due this same of behavior.