#pragma once #include "Backup.h" #include "../Interface/Types.h" #include "dao/ServerBackupDao.h" #include #include "server_settings.h" #include "fileclient/FileClient.h" #include "fileclient/FileClientChunked.h" #include #include "file_metadata.h" class ClientMain; class BackupServerHash; class BackupServerPrepareHash; class ServerPingThread; class FileIndex; namespace { const unsigned int status_update_intervall=1000; const unsigned int eta_update_intervall=60000; } struct SContinuousSequence { SContinuousSequence() : id(-1), next(-1) { } SContinuousSequence(int64 id, int64 next) : id(id), next(next) { } int64 id; int64 next; }; class FileBackup : public Backup { public: FileBackup(ClientMain* client_main, int clientid, std::wstring clientname, LogAction log_action, bool is_incremental, int group, bool use_tmpfiles, std::wstring tmpfile_path, bool use_reflink, bool use_snapshots); ~FileBackup(); bool getResult(); bool hasEarlyError(); bool hasDiskError(); int getBackupid() { return backupid; } std::map getContinuousSequences() { return continuous_sequences; } static std::wstring convertToOSPathFromFileClient(std::wstring path); protected: virtual bool doBackup(); virtual bool doFileBackup() = 0; ServerBackupDao::SDuration interpolateDurations(const std::vector& durations); bool request_filelist_construct(bool full, bool resume, int group, bool with_token, bool& no_backup_dirs, bool& connect_fail); void logVssLogdata(); void getTokenFile(FileClient &fc, bool hashed_transfer ); std::string clientlistName( int group, bool new_list=false ); void createHashThreads(bool use_reflink); void destroyHashThreads(); _i64 getIncrementalSize(IFile *f, const std::vector &diffs, bool all=false); void calculateEtaFileBackup( int64 &last_eta_update, int64 ctime, FileClient &fc, FileClientChunked* fc_chunked, int64 linked_bytes, int64 &last_eta_received_bytes, double &eta_estimated_speed, _i64 files_size ); bool hasChange(size_t line, const std::vector &diffs); std::wstring fixFilenameForOS(const std::wstring& fn); bool link_file(const std::wstring &fn, const std::wstring &short_fn, const std::wstring &curr_path, const std::wstring &os_path, const std::string& sha2, _i64 filesize, bool add_sql, const FileMetadata& metadata, const FileMetadata& parent_metadata); void sendBackupOkay(bool b_okay); void notifyClientBackupSuccessfull(void); void waitForFileThreads(); bool verify_file_backup(IFile *fileentries); std::string getSHA256(const std::wstring& fn); std::string getSHA512(const std::wstring& fn); bool constructBackupPath(bool with_hashes, bool on_snapshot, bool create_fs); bool constructBackupPathCdp(); std::string systemErrorInfo(); void saveUsersOnClient(); void createUserViews(IFile* file_list_f); bool createUserView(IFile* file_list_f, const std::vector& ids, std::string accoutname, const std::vector& identical_permission_roots); std::vector findIdenticalPermissionRoots(IFile* file_list_f, const std::vector& ids); void deleteBackup(); int group; bool use_tmpfiles; std::wstring tmpfile_path; bool use_reflink; bool use_snapshots; bool with_hashes; bool cdp_path; std::wstring backuppath; std::wstring dir_pool_path; std::wstring backuppath_hashes; std::wstring backuppath_single; IPipe *hashpipe; IPipe *hashpipe_prepare; BackupServerHash *bsh; THREADPOOL_TICKET bsh_ticket; BackupServerPrepareHash *bsh_prepare; THREADPOOL_TICKET bsh_prepare_ticket; std::auto_ptr local_hash; ServerPingThread* pingthread; THREADPOOL_TICKET pingthread_ticket; std::map continuous_sequences; std::auto_ptr fileindex; bool disk_error; int backupid; };