package smserve_plugins;

import java.io.File;
import java.util.GregorianCalendar;
/**
 * This Class is used, to create backups frequently.
 * This will prevent greater Data loss.
 * @author zeri
 * @category live-and-death
 */
public class SMbackup extends Thread {
	private SMdump dump;
	public void run() {
		String name="/var/tmp/SMDump"+GregorianCalendar.MILLISECOND+GregorianCalendar.SECOND+GregorianCalendar.MINUTE+GregorianCalendar.HOUR+GregorianCalendar.DAY_OF_YEAR+GregorianCalendar.YEAR;
		while(true) {
			int i=0;
			File f;
		try {
			String newname=name+i;
			String oldname="";
			System.out.println("Backup now");
			dump=new SMdump(newname);
			dump.dumpMails();
			i++;
			f=new File(oldname);
			f.delete();
			f=null;
			Thread.sleep(10000);
			oldname=newname;
		} catch(Exception e){
			System.out.println(e);
		}
		}
	}
}
