Exemple #1
0
// daemon controls the backup processors
func daemon(ticker *time.Ticker, quit <-chan bool) {
	config := stash.NewConfig()
	for {
		select {
		case <-ticker.C:
			processBackups(config)
		case <-quit:
			ticker.Stop()
			return
		}
	}
}
Exemple #2
0
func runDelete(args []string) {
	config := stash.NewConfig()
	reader := bufio.NewReader(os.Stdin)
	color.Red("WARNING! Deleted entries cannot be recovered")
	color.Blue("Please choose one of the following entries: ")
	for _, entry := range config.Entries {
		color.Magenta("	%s", entry.Name)
	}
	fmt.Println()
	fmt.Print("Entry to delete (case-sensitive): ")
	text, _ := reader.ReadString('\n')
	text = strings.TrimSpace(text)
	err := config.DeleteEntry(text)
	if err != nil {
		color.Red("Fatal error deleting an entry: %s", err)
		os.Exit(1)
	}
}
Exemple #3
0
func addAmazon(name string, foldersList []string, freq time.Duration) {

	confEntry := stash.ConfigEntry{
		Name:        name,
		Folders:     foldersList,
		Type:        "Amazon",
		Credentials: userInputCredentials(),
		Frequency:   freq,
	}

	config := stash.NewConfig()
	// Verify that name is not already taken:
	verifyName(name, config)
	if err := config.AddDestination(confEntry); err != nil {
		color.Red("Fatal error adding backup destination: ", err)
		os.Exit(1)
	}
}
Exemple #4
0
func runList(args []string) {
	config := stash.NewConfig()
	col := color.New(color.FgMagenta)
	color.New(color.FgBlue, color.Bold).Println("Current Backup Destinations:")
	fmt.Println()
	for _, entry := range config.Entries {
		col.Printf("Name:		")
		fmt.Println(entry.Name)
		col.Printf("Folders:	")
		fmt.Println(entry.Folders)
		col.Printf("Type:		")
		fmt.Println(entry.Type)
		col.Printf("Frequency:	")
		fmt.Println("Every ", entry.Frequency)
		col.Printf("Last Backup:	")
		// .Format takes an example string for how the stamp should look
		fmt.Println(entry.LastBak.Format("Jan 2, 2006 at 3:04pm (MST)"))
		fmt.Println()
	}
}