Skip to content

Commit

Permalink
Changed project name
Browse files Browse the repository at this point in the history
  • Loading branch information
cbell504 committed Jan 28, 2020
1 parent 4663f8d commit 4ea38e2
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7 deletions.
3 changes: 3 additions & 0 deletions backedup/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python3

from .constants import Constants
59 changes: 59 additions & 0 deletions backedup/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3

from backedup import Constants

import datetime
import logging
import os
import shutil


def main():
logging.basicConfig(filename='backedup.log', level=logging.INFO)
create_backedup_folder()
if(not did_backup_today()):
backup_directory = create_backup_directory()
create_backup(backup_directory)
print(Constants.DONE)


def create_backedup_folder():
if(os.path.isdir(Constants.DEST_FOLDER)):
print(Constants.FOLDER_EXIST)
return True
else:
os.mkdir(Constants.DEST_FOLDER)


def did_backup_today():
dest_folder_list = os.listdir(Constants.DEST_FOLDER)
for folder in dest_folder_list:
if(str(datetime.date.today()) in folder):
print(Constants.OUTPUT_FOLDER_EXIST)
return True
else:
print(Constants.STARTING_UPDATE)
return False


def create_backup(backup_directory):
shutil.copytree(src=Constants.SRC_FOLDER,
dst=backup_directory,
ignore=_logpath)


def create_backup_directory():
backup_directory = Constants.DEST_FOLDER + \
Constants.NEW_UPDATE_FOLDER + str(datetime.date.today())
if(os.path.isdir(backup_directory)):
print(Constants.OUTPUT_FOLDER_EXIST)
return backup_directory


def _logpath(path, names):
logging.info('Copying %s' % path)
return []


if __name__ == "__main__":
main()
11 changes: 11 additions & 0 deletions backedup/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3


class Constants:
DONE = "DONE!"
FOLDER_EXIST = "The Backupper folder exist!"
DEST_FOLDER = "/media/passport/backupper"
NEW_UPDATE_FOLDER = "/backupper_"
OUTPUT_FOLDER_EXIST = "An update has already occurred today!"
SRC_FOLDER = "/home/chris"
STARTING_UPDATE = "Starting Backup..."
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
from setuptools import setup

setup(
name='backupper',
packages=['backupper'],
package_dir={'backupper': 'backupper'},
name='backedup',
packages=['backedup'],
package_dir={'backedup': 'backedup'},
version='1.0.0',
description='simple backup script',
description='A simple backup script',
author='Azurras',
url='https://github.com/Azurras/backup.git',
url='https://github.com/Azurras/backedup.git',
author_email='',
keywords=['backup'],
keywords=['backedup'],
entry_points={'console_scripts': [
'backupper = backupper.__main__:main',
'backedup = backedup.__main__:main',
], },
)

0 comments on commit 4ea38e2

Please sign in to comment.