code: func (m *Manager) snapshot(path string, checkDup bool) error {
  	// Build the snapshot
  	s := snapshot{
  		Version: snapshotVersion,
  		Proxies: make(map[string]snapshotProxy, len(m.proxies)),
  	}
  	for id, p := range m.proxies {
  		// Get the snapshot configuration. If the configuration is nil or
  		// empty then we don't persist this proxy.
  		config := p.MarshalSnapshot()
  		if len(config) == 0 {
  			continue
  		}
  
  		s.Proxies[id] = snapshotProxy{
  			Mode:   proxyExecMode(p),
  			Config: config,
  		}
  	}
  
  	// Dup detection, if the snapshot is identical to the last, do nothing
  	if checkDup && reflect.DeepEqual(m.lastSnapshot, &s) {
  		return nil
  	}
  
  	// Encode as JSON
  	encoded, err := json.Marshal(&s)
  	if err != nil {
  		return err
  	}
  
  	// Write the file
  	err = file.WriteAtomic(path, encoded)
  
  	// If we are checking for dups and we had a successful write, store
  	// it so we don't rewrite the same value.
  	if checkDup && err == nil {
  		m.lastSnapshot = &s
  	}
  	return err
  }
docs: // snapshot is the internal function analogous to Snapshot but expects
  // a lock to already be held.
  //
  // checkDup when set will store the snapshot on lastSnapshot and use
  // reflect.DeepEqual to verify that its not writing an identical snapshot.