your_data = {'rose': 'red',
'sun': 'orange',
'sky': 'blue'}
with open('save.txt','w') as f:
while True:
print(your_data, file=f)
This is an sample program. here the dictionaries are copied to the file named save.txt. Actually I am running this program in raspberry pi and if the power suddenly gets off, the datas stored completely gets erased. I want my program to start again from the previous end of the program or I should have an backup from where I can restart my program.