src/FS/File/BackupCleaner.php
public function keepLastOfMonth( $filters = array(), $verbose = FALSE, $testOnly = FALSE ){
		$dates	= $this->filterDateTree( $this->getDateTree(), $filters );
		foreach( $dates as $year => $months ){
			if( $verbose )
				remark( "..Year: ".$year );
			foreach( $months as $month => $days ){
				if( $verbose )
					remark( "....Month: ".$month );
				$keep	= array_pop( $days );
				if( $verbose )
					remark( "......Keep: ".$this->path.$this->prefix.$keep.".".$this->ext );
				foreach( $days as $day => $date ){
					if( $this->vault ){
						$fileSource	= $this->path.$this->prefix.$date.".".$this->ext;
						$fileTarget	= $this->vault.$this->prefix.$date.".".$this->ext;
						if( $verbose )
							remark( "......Move: ".$fileSource." to  ".$fileTarget );
						if( !$testOnly )
							rename( $fileSource, $fileTarget );
					}
					else{
						$fileName	= $this->path.$this->prefix.$date.".".$this->ext;
						if( $verbose )
							remark( "......Delete: ".$fileName );
						if( !$testOnly )
							unlink( $fileName );
					}
				}
			}
		}
	}
public function keepLastOfMonth( $filters = array(), $verbose = FALSE, $testOnly = FALSE ){
		$dates	= $this->filterDateTree( $this->getDateTree(), $filters );
		foreach( $dates as $year => $months ){
			if( $verbose )
				remark( "..Year: ".$year );
			foreach( $months as $month => $days ){
				if( $verbose )
					remark( "....Month: ".$month );
				$keep	= array_pop( $days );
				if( $verbose )
					remark( "......Keep: ".$this->path.$this->prefix.$keep.".".$this->ext );
				foreach( $days as $day => $date ){
					if( $this->vault ){
						$fileSource	= $this->path.$this->prefix.$date.".".$this->ext;
						$fileTarget	= $this->vault.$this->prefix.$date.".".$this->ext;
						if( $verbose )
							remark( "......Move: ".$fileSource." to  ".$fileTarget );
						if( !$testOnly )
							rename( $fileSource, $fileTarget );
					}
					else{
						$fileName	= $this->path.$this->prefix.$date.".".$this->ext;
						if( $verbose )
							remark( "......Delete: ".$fileName );
						if( !$testOnly )
							unlink( $fileName );
					}
				}
			}
		}
	}
public function keepLastOfMonth ( $ filters = array ( ) , $ verbose = FALSE , $ testOnly = FALSE ) { $ dates = $ this -> filterDateTree ( $ this -> getDateTree ( ) , $ filters ) ; foreach ( $ dates as $ year => $ months ) { if ( $ verbose ) remark ( "..Year: " . $ year ) ; foreach ( $ months as $ month => $ days ) { if ( $ verbose ) remark ( "....Month: " . $ month ) ; $ keep = array_pop ( $ days ) ; if ( $ verbose ) remark ( "......Keep: " . $ this -> path . $ this -> prefix . $ keep . "." . $ this -> ext ) ; foreach ( $ days as $ day => $ date ) { if ( $ this -> vault ) { $ fileSource = $ this -> path . $ this -> prefix . $ date . "." . $ this -> ext ; $ fileTarget = $ this -> vault . $ this -> prefix . $ date . "." . $ this -> ext ; if ( $ verbose ) remark ( "......Move: " . $ fileSource . " to  " . $ fileTarget ) ; if ( ! $ testOnly ) rename ( $ fileSource , $ fileTarget ) ; } else { $ fileName = $ this -> path . $ this -> prefix . $ date . "." . $ this -> ext ; if ( $ verbose ) remark ( "......Delete: " . $ fileName ) ; if ( ! $ testOnly ) unlink ( $ fileName ) ; } } } } }
Removes all files except the last of each month.
@access		public
@param		array		$filters	List of filters to apply on dates before
@param		boolean		$verbose	Flag: show whats happening, helpful for test mode, default: FALSE
@param		boolean		$testOnly	Flag: no real actions will take place, default: FALSE
@return		void
Removes all files except the last of each month .