Sybase Sql Anywhere Backup - sybase

Sybase Sql Anywhere:
When i backup a database while a transaction is stil active and i truncate the transaction log while backuping, what's the outcome?
Transaction'd data changes are not in the backup
Transaction'd data changes are in the truncated transaction log file
Thx.

Depends on your isolation level.
Under typical circumstances the transaction would not be contained within the backup.
Also, the transaction log will only truncate up to the oldest open transaction.

Related

I have a SQL Server file backup file (.bak) i want to get detail of each transaction

I have a SQL Server backup (.bak) file, and I want use fn_dump_dblog (undocumented function) on it to get all transaction history from it.
I read this article https://www.mssqltips.com/sqlservertip/3555/read-sql-server-transaction-log-backups-to-find-when-transactions-occurred/
and do the same but fn_dump_dblog result only shows query of restoring of that database (most of the rows are NULL)
Please help me - what am I doing wrong? Or there is any alternative way to do that?
Note: I am taking backup in full mode
I already tried fn_dblog but that does not help me
I can not use fn_dblog or fn_dump_dblog on database directly so I am taking backup (.bak file) every day and then restore it to my local system.
can i get transaction history if i have .trn file ?
You can't. A database backup only contains a minimal amount of log records, see How much transaction log a backup includes. If there was no other activity, then the only transaction captured would be the BACKUP itself, as you see.
You did not specify if is a database backup or a log backup, I made an educated guess that you have a database backup. A log backup would contain only log records, but log backup implies a recovery plan and a log chain, you would have mentioned if they were in place.

How to rollback database only with MDF and LDF files but without backup file?

Is it possible to rollback only with MDF and LDF files but without backup file?
I worked days but suddenly it's gone. It's important to me.
Yes, it is possible, but only if:
Your database is in full or bulk-logged recovery mode, and
You had taken at least one full backup prior to the point of failure, and
There is a complete chain of transaction log backups since the last full backup, or
There were no transaction log backups since then.
What you need to do is:
Take transaction log backup of your database;
Restore your last full backup as a new database with NO_RECOVERY option;
Restore all necessary transaction log backups, if any, again with NO_RECOVERY;
Restore the most recent transaction log backup you just made in #1 with RECOVERY and STOPAT options. In the latter, you can specify the exact time on which you want your database to be restored.
For full syntax, see RESTORE.

sqlserver 2012 320gb log file

just been looking on our sqlserver running mssql 2012 and the c drive is filling up quick. I've had a look around and there is a "LogLiveV2.log" file which just over 320gb in
C:\Program Files\Microsoft SQL Server\MSSQL11.AA9SQLSERVER\MSSQL\DATA.
does anyone know what it is and how I can either shrink it or delete it "
The log file holds the database transaction log.
Just set the database recovery mode to SIMPLE, then forget about LDF -
it will be small. This is the recommended solution for most of the
cases.
Note The transaction logs are very important for maintaining the
transnational integrity of the database. You can shrink the transnational log file but do not delete the transaction
log files, even after you make a backup of your database and the
transaction logs.
If your database is not in simple recovery model, the log files are not reclaimed automatically, so you have to backup the log files to truncate them.
If you do not want to backup them, you have to set the recovery model to Simple, then run a DBCC SHRINKFILE command to shrink the logfile.
You can read more at http://msdn.microsoft.com/en-us/library/ms186865.aspx (Transaction Log Truncation section)
To avoid filling up the transaction log of a database, routine backups are essential. Under the simple recovery model, log truncation occurs automatically after you back up the database, and under the full recovery model, after you back up the transaction log. However, sometimes the truncation process can be delayed. For information about factors that can delay log truncation, see The Transaction Log (SQL Server).
About recovery models: http://msdn.microsoft.com/en-us/library/ms189275.aspx
The .log file and the .ldf files are two different things. If it is the .ldf file, then all answers posted about SIMPLE RECOVERY and SHRINKFILE are correct. However, if you are referring to a .log file, it would be an event log file of some sort.

What are the requirements for SQL Server taking transaction log backup in database set for Full Recovery Model?

I have implemented Ola Hallengren's maintenance solution and transaction log backup is running every hour. I was going to perform restore test for one particular database today and noticed that although the database is in Full Recovery Mode there have been no transaction log backup taken. There were about 100 other databases running on this particular instance and about 95 of them had transaction log backups successfully taken.
I have just recently taken over this environment so I have no history as to how things have been set up or how these databases have been created.
When comparing the settings I against a database which was getting transaction log backup taken I see that the "Log Reuse Wait Description" is set to DATABASE_SNAPSHOT_CREATION for the database that does not have transaction log backup but LOG_BACKUP or NOTHING for those having successful transaction log backups taken.
I checked backup history and those that had transaction log backup today had history of successful backup last months but there was no history of any transaction log backup being taking for the databases that I am not seeing transaction log backup. I also checked and there are no long running transactions going on.
What should I check and how should I fix it so that the log backups start to generate for all the user databases?
And is there something I can do to prevent this from happening in future?
Thanks in advance!
When you restored the last full backup, the database was in simple recovery mode. Databases in simple recovery mode do not use transaction log backups. In order to do transaction log backups you need:
Database in Full Recovery mode.
At least one full backup after switching to Full Recovery mode.

SQL Server LOG Data recovery

I was wondering how you can recover data from your logfile.
I'm using sql 2005 (full backup).
The problem is that a service cleared my data last night (which it shouldn't have).
and now I want to recover those rows that were deleted before.
can anyone tell me how I can do this?
As long as you have a backup of your database from before the delete and then all transaction log backups that have been made since the last database backup then you will be able to restore to a point in time.
The first thing to do is take a backup of the transaction log.
Then you restore your last database backup and all transaction log backups since then up to the point in time just before the delete.
See this MSDN Article on how to do it.
I would suggest that you leave your existing database in place as it is and restore the backups to a new database. Then you can write some scripts to transfer the required data back into your live database.
First of all, your database must be in the full recovery model and you must have a full chain of transaction log backups - a series of log records having an unbroken sequence of log sequence numbers (LSNs)
The log backup chain is started when a full database backup is made or the recovery model is switched from SIMPLE to FULL and a full backup is made. After that, transaction log backups are created on regular basis. The log backup chain can be broken only in two ways:
Overwriting the backup set
Switching from FULL to SIMPLE or BULK LOGGED recovery models
Breaking the log backup chain can lead to missing transaction information
You can restore to a point in time using:
SQL Server Management Studio, as shown in the link Robin provided
Using T-SQL and the STOPAT option
Syntax
RESTORE LOG database_name
FROM <backup_device>
WITH STOPAT = time, RECOVERY…
Use a third party tool, such as ApexSQL Log which can not only restore to a specific point in time, but selectively roll back only the transdactions you selected
You can find the steps for all listed options here: Restore a database to a point in time
Disclaimer: I work for ApexSQL as a Support engineer
Your data can be recovered only in case:
1) database uses full recovery model;
2) you have full backup that you make before accidental deleting;
3) you have have NOT recover or backup again this database yet.
If this is correct, you should:
1) make transaction log backup;
2) restore database from full backup WITH NORECOVERY option;
3) restore transaction log using STOPAT option.
To restore transaction log files to a point-in-time your database must run under full recovery model. So firstly you have to restore the latest full database backup:
RESTORE DATABASE *database* FROM DISK = 'D:/Full.bak' WITH NORECOVERY, REPLACE
The next step is to restore the last differential database backup:
RESTORE DATABASE *database* FROM DISK = 'D:/Diff.bak' WITH NORECOVERY
And then restore all transaction log backups that have made since last differential backup in correct sequence
RESTORE LOG *database* FROM DISK = 'D:/log1.bak' WITH NORECOVERY
RESTORE LOG *database* FROM DISK = 'D:/log2.bak' WITH NORECOVERY
RESTORE LOG *database* FROM DISK = 'D:/log3.bak' WITH NORECOVER
The last one transaction log backup that must be restored is the transaction log backup that have been made after the failure occurred with stopat option. After stopat option, you should set up the time to which you want to restore your database.
RESTORE LOG *database* FROM DISK = 'D:/log4.bak' WITH STOPAT = '2015-11-26 16:22:40.000', RECOVERY

Resources