This is how I keep backup for seven days:
Use Master
Declare
@new_device nvarchar(40),
@new_file nvarchar(40),
@old_device nvarchar(40)
set @new_device='MyDB'+convert(char(8),getdate(),12)
set @new_file='d:\mssql\BACKUP\MyDB'+convert(char(8),getdate(),12)
set @old_device='MyDB'+convert(char(8),(getdate()-7),12)
EXEC sp_addumpdevice 'disk',@new_device,@new_file
BACKUP DATABASE MyDB TO @new_device
If exists (Select name from sysdevices
...