src/Webiny/BackupService/Lib/S3.php
public function moveOldBackup()
    {
        Service::$log->msg('S3: moving old backups');
        // remove the 2-day file
        $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-2days-old';
        if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFile)) {
            $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFile);
        }

        // copy current 1-day file to 2-day
        $sourceFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-1day-old';
        $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-2days-old';
        if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $sourceFile)) {
            $this->s3Instance->copyObject($this->s3Config->Bucket, $sourceFile, $this->s3Config->Bucket,
                $destinationFile);
        }

        // remove the old 1-day file
        $destinationFileTemp = rtrim($this->s3Config->RemotePath, '/') . '/backup-1day-old';
        if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFileTemp)) {
            $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFileTemp);
        }

        Service::$log->msg('S3: moving old backups done');

        return $destinationFile;
    }
public function moveOldBackup()
    {
        Service::$log->msg('S3: moving old backups');
        // remove the 2-day file
        $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-2days-old';
        if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFile)) {
            $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFile);
        }

        // copy current 1-day file to 2-day
        $sourceFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-1day-old';
        $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-2days-old';
        if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $sourceFile)) {
            $this->s3Instance->copyObject($this->s3Config->Bucket, $sourceFile, $this->s3Config->Bucket,
                $destinationFile);
        }

        // remove the old 1-day file
        $destinationFileTemp = rtrim($this->s3Config->RemotePath, '/') . '/backup-1day-old';
        if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFileTemp)) {
            $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFileTemp);
        }

        Service::$log->msg('S3: moving old backups done');

        return $destinationFile;
    }
public function moveOldBackup ( ) { Service :: $ log -> msg ( 'S3: moving old backups' ) ; // remove the 2-day file $ destinationFile = rtrim ( $ this -> s3Config -> RemotePath , '/' ) . '/backup-2days-old' ; if ( $ this -> s3Instance -> doesObjectExist ( $ this -> s3Config -> Bucket , $ destinationFile ) ) { $ this -> s3Instance -> deleteObject ( $ this -> s3Config -> Bucket , $ destinationFile ) ; } // copy current 1-day file to 2-day $ sourceFile = rtrim ( $ this -> s3Config -> RemotePath , '/' ) . '/backup-1day-old' ; $ destinationFile = rtrim ( $ this -> s3Config -> RemotePath , '/' ) . '/backup-2days-old' ; if ( $ this -> s3Instance -> doesObjectExist ( $ this -> s3Config -> Bucket , $ sourceFile ) ) { $ this -> s3Instance -> copyObject ( $ this -> s3Config -> Bucket , $ sourceFile , $ this -> s3Config -> Bucket , $ destinationFile ) ; } // remove the old 1-day file $ destinationFileTemp = rtrim ( $ this -> s3Config -> RemotePath , '/' ) . '/backup-1day-old' ; if ( $ this -> s3Instance -> doesObjectExist ( $ this -> s3Config -> Bucket , $ destinationFileTemp ) ) { $ this -> s3Instance -> deleteObject ( $ this -> s3Config -> Bucket , $ destinationFileTemp ) ; } Service :: $ log -> msg ( 'S3: moving old backups done' ) ; return $ destinationFile ; }
Moves around the current backups on S3 and does some cleanup before new backups are created.
Moves around the current backups on S3 and does some cleanup before new backups are created .